Skip to content

Update task for installing Python packages and update requests version

Nick Westbury requested to merge nwestbury/python-package-installation into main

What does this MR do?

The code changes involve updating the versions of Python packages used in the common role of an Ansible project. Specifically, the requests package is downgraded from version 2.31.0 to 2.29.0. These changes ensure that the Ansible role continues to function properly with the specified Python versions and dependencies.

When running the HAProxy role for the first time, the run will fail with the below, these seems to be related to the version of the requests package being installed.

TASK [haproxy : Start HAProxy External Docker] *********************************************************************
fatal: [geo-1k-eu-west1-haproxy-external-1]: FAILED! => changed=false
  attempts: 2
  msg: 'Error connecting: Error while fetching server API version: request() got an unexpected keyword argument ''chunked'''

It was also found when trying different versions of the package that the GET command Install python packages doesn't actually install the packages. After changing the package version of requests to install and rerunning the command, nothing would be changed. Once updated to use a loop the packages would be installed as expected.

# Before

TASK [common : Install python packages] ****************************************************************************
ok: [geo-1k-eu-west1-haproxy-external-1]

pip freeze | grep requests
requests==2.22.0

# After

TASK [common : Install python packages] ****************************************************************************
ok: [geo-1k-eu-west1-haproxy-external-1] => (item=netaddr<=1.21.1)
ok: [geo-1k-eu-west1-haproxy-external-1] => (item=PyYAML<=6.0.1)
changed: [geo-1k-eu-west1-haproxy-external-1] => (item=docker<=7.0.0)
ok: [geo-1k-eu-west1-haproxy-external-1] => (item=pexpect<=4.9.0)
ok: [geo-1k-eu-west1-haproxy-external-1] => (item=psycopg2<=2.9.9)
changed: [geo-1k-eu-west1-haproxy-external-1] => (item=requests<=2.31.0)

pip freeze | grep requests
requests==2.29.0

Related issues

Author's checklist

When ready for review, the Author applies the workflowready for review label and mention @gl-quality/get-maintainers:

  • Merge request:
    • Corresponding Issue raised and reviewed by the GET maintainers team.
    • Merge Request Title and Description are up-to-date, accurate, and descriptive
    • MR targeting the appropriate branch
    • MR has a green pipeline
    • MR has no new security alerts in the widget from the Secret Detection and IaC Scan (SAST) jobs.
  • Code:
    • Check the area changed works as expected. Consider testing it in different environment sizes (1k,3k,10k,etc.).
    • Documentation created/updated in the same MR.
    • If this MR adds an optional configuration - check that all permutations continue to work.
    • For Terraform changes: set up a previous version environment, then run a terraform plan with your new changes and ensure nothing will be destroyed. If anything will be destroyed and this can't be avoided please add a comment to the current MR.
  • Create any follow-up issue(s) to support the new feature across other supported cloud providers or advanced configurations. Create 1 issue for each provider/configuration. Contact the Quality Enablement team if unsure.
Edited by Nick Westbury

Merge request reports