Changeset - c8b5cf1283e0
[Not reviewed]
0 2 0
Branko Majic (branko) - 7 months ago 2024-03-17 12:38:03
branko@majic.rs
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).
2 files changed with 14 insertions and 0 deletions:
0 comments (0 inline, 0 general)
docs/releasenotes.rst
Show inline comments
 
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
 
-----
 

	
 
Dropped support for Python 2.7 and Debian 10 Buster. Added support for
 
Debian 12 Bookworm. Numerous minor improvements and fixes.
 

	
 
**Breaking changes:**
 

	
 
* All roles
 

	
 
  * Dropped support for Debian 10 (Buster).
 
  * Added support for Debian 12 (Bookworm).
roles/common/tasks/main.yml
Show inline comments
 
@@ -365,35 +365,39 @@
 
      - "/usr/bin/python3"
 
      - "-c"
 
      - "import sys; print(sys.version.split(' ')[0])"
 
  changed_when: false
 
  register: python_interpreter_version
 

	
 
- name: Retrieve virtual environment Python interpreter version (if initialised)
 
  command:
 
    argv:
 
      - "/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
 
  register: virtualenv_python_version
 

	
 
- name: Retrieve virtual environment prompt
 
  command:
 
    argv:
 
      - "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
 

	
 
- name: Remove virtual environment in case of mismatches
 
  file:
 
    path: "/var/lib/pipreqcheck/virtualenv"
 
    state: absent
 
  when: |
 
    virtualenv_python_version.rc != 0 or
 
    virtualenv_python_version.stdout.strip() != python_interpreter_version.stdout.strip() or
 
    current_virtualenv_prompt.stdout != "(pipreqcheck) "
0 comments (0 inline, 0 general)