Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework how "EXTERNALLY-MANAGED" are handle using flag pip_externally_managed #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

socheatsok78
Copy link

@socheatsok78 socheatsok78 commented May 15, 2024

Add ability to control how "EXTERNALLY-MANAGED" python base environment via flag pip_externally_managed (boolean).

If pip_externally_managed: true, we preserver or create the EXTERNALLY-MANAGED file in it intended place. Otherwise remove it as original impl.

I'm not entirely sure if it is the right way to do this, but i'm open to suggestion.

Ref #57 (comment)

@socheatsok78 socheatsok78 marked this pull request as ready for review May 15, 2024 09:03
Comment on lines +4 to +13
- name: Get installed python3 version
ansible.builtin.shell: python3 --version | awk '{split($2, a, "."); print a[1] "." a[2]}'
register: py3ver
changed_when: false

- name: Ensure "{{ 'absent' if not pip_externally_managed else 'present' }}" of EXTERNALLY-MANAGED's Python base environments
ansible.builtin.file:
path: "/usr/lib/python{{ py3ver.stdout }}/EXTERNALLY-MANAGED"
state: "{{ 'absent' if not pip_externally_managed else 'touch' }}"
when: py3ver is defined and py3ver.stdout is version_compare('3.11', '>=')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have other implementation which could replace this whole thing

- name: Ensure "{{ 'absent' if not pip_externally_managed else 'present' }}" of EXTERNALLY-MANAGED's Python base environments
  vars:
    python_version: "{{ ansible_facts.python_version }}"
    python_version_short: "{{ ansible_facts.python.version.major }}.{{ ansible_facts.python.version.minor }}"
  ansible.builtin.file:
    path: "/usr/lib/python{{ python_version_short }}/EXTERNALLY-MANAGED"
    state: "{{ 'absent' if not pip_externally_managed else 'touch' }}"
  when: python_version is defined and python_version is version_compare('3.11', '>=')

Which do you think is a better fit for this? @geerlingguy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant