From 956d7705c0127dd2db0d68df73d02e8b3adf4f72 2024-03-17 12:39:35 From: Branko Majic Date: 2024-03-17 12:39:35 Subject: [PATCH] MAR-234: Use the pipreqcheck user when checking the Python version and prompt: - Using the root account can result in incorrect permissions being set on the Python cache (__pycache__) directories, which can further cause permission issues for the pirpeqcheck user itself. - The prompt also makes more sense to check in context of the virtual environment user (since that's the one that will normally get used with the virtual environment itself). --- diff --git a/docs/releasenotes.rst b/docs/releasenotes.rst index f7b054a16faa73fd19259fbdc653f83284866bdf..e31d9566b7ecefe1c0170bf18148387b9a9410c1 100644 --- a/docs/releasenotes.rst +++ b/docs/releasenotes.rst @@ -2,6 +2,16 @@ Release notes ============= +x.y.z +----- + +* ``common`` role + + * Fixed permission errors with Python cache directories in the pip + requirements upgrade checks virtual environment that can happen if + the initial virtual environment set-up fails. + + 8.0.0 ----- diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index ab4fa0a2b80304d422687dc8dfc30108daa69210..7538388c9b4c53b04ab6ddbc2bf0c46e7e0abeb5 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -374,6 +374,8 @@ - "/var/lib/pipreqcheck/virtualenv/bin/python" - "-c" - "import sys; print(sys.version.split(' ')[0])" + become: true + become_user: "pipreqcheck" # Virtual environment perhaps does not exist. failed_when: false changed_when: false @@ -385,6 +387,8 @@ - "bash" - "-c" - "source '/var/lib/pipreqcheck/virtualenv/bin/activate'; printenv PS1" + become: true + become_user: "pipreqcheck" failed_when: false changed_when: false register: current_virtualenv_prompt