Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions roles/os_openstackclient/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
os_openstackclient_venv:
# Whether to install package dependencies.
os_openstackclient_install_package_dependencies: true
# Value to use for the pip module's `virtualenv_command` argument when creating the virtualenv
os_openstackclient_virtualenv_command: "{{ os_openstackclient_virtualenv_python ~ ' -m venv' if os_openstackclient_venv else omit }}"
# Python interpreter to use in virtualenv command; `os_virtualenv_python` can be used to set this collection wide.
os_openstackclient_virtualenv_python: "{{ os_virtualenv_python | default('python3.' ~ ansible_facts.python.version.minor) }}"

# State of the openstackclient package.
os_openstackclient_state: present
Expand Down
10 changes: 9 additions & 1 deletion roles/os_openstackclient/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
become: "{{ ansible_facts.system != 'Darwin' }}"
when: os_openstackclient_install_package_dependencies | bool

- name: Remove virtualenv if python version is stale
ansible.builtin.file:
path: "{{ os_openstackclient_venv }}"
state: absent
when:
- os_openstackclient_venv is not none
- (os_openstackclient_venv ~ '/bin/python') | realpath != os_openstackclient_virtualenv_python | realpath

- name: Ensure the virtualenv directory exists
when: os_openstackclient_venv is not none
block:
Expand All @@ -40,7 +48,7 @@
name: "{{ item.name }}"
state: latest
virtualenv: "{{ os_openstackclient_venv or omit }}"
virtualenv_command: "{{ 'python3.' ~ ansible_facts.python.version.minor ~ ' -m venv' if os_openstackclient_venv else omit }}"
virtualenv_command: "{{ os_openstackclient_virtualenv_command }}"
with_items:
- { name: pip }
- { name: setuptools }
Expand Down
4 changes: 3 additions & 1 deletion roles/os_openstacksdk/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Path to a directory in which to create a virtualenv.
os_openstacksdk_venv:
# Value to use for the pip module's `virtualenv_command` argument when creating the virtualenv
os_openstacksdk_virtualenv_command: "{{ 'python3.' ~ ansible_facts.python.version.minor ~ ' -m venv' if os_openstacksdk_venv else omit }}"
os_openstacksdk_virtualenv_command: "{{ os_openstacksdk_virtualenv_python ~ ' -m venv' if os_openstacksdk_venv else omit }}"
# Python interpreter to use in virtualenv command; `os_virtualenv_python` can be used to set this collection wide.
os_openstacksdk_virtualenv_python: "{{ os_virtualenv_python | default('python3.' ~ ansible_facts.python.version.minor) }}"

# Whether to install package dependencies.
os_openstacksdk_install_package_dependencies: true
Expand Down
8 changes: 8 additions & 0 deletions roles/os_openstacksdk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
become: "{{ ansible_facts.system != 'Darwin' }}"
when: os_openstacksdk_install_package_dependencies | bool

- name: Remove virtualenv if python version is stale
ansible.builtin.file:
path: "{{ os_openstacksdk_venv }}"
state: absent
when:
- os_openstacksdk_venv is not none
- (os_openstacksdk_venv ~ '/bin/python') | realpath != os_openstacksdk_virtualenv_python | realpath

- name: Ensure the virtualenv directory exists
when: os_openstacksdk_venv is not none
block:
Expand Down