From e6ff6912083bc7118e43f9a5f9fded94bac877c7 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 28 Oct 2020 14:21:08 +0100 Subject: [PATCH] Ensure PATH contains the virtual environment when validating CLI Change-Id: I1c3f195636bb63cad19638c32631d2b753c7ea40 --- .../bifrost-keystone-client-config/defaults/main.yml | 4 ++++ .../bifrost-keystone-client-config/tasks/validate.yml | 11 +++++------ .../notes/validate-path-5c303903900dcd65.yaml | 5 +++++ 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/validate-path-5c303903900dcd65.yaml diff --git a/playbooks/roles/bifrost-keystone-client-config/defaults/main.yml b/playbooks/roles/bifrost-keystone-client-config/defaults/main.yml index efec60584..0ea395c17 100644 --- a/playbooks/roles/bifrost-keystone-client-config/defaults/main.yml +++ b/playbooks/roles/bifrost-keystone-client-config/defaults/main.yml @@ -18,6 +18,10 @@ ironic_inspector_api_url: "{{ api_protocol }}://{{ internal_ip }}:5050" # Ensure that Ansible is using python interpreter and dependencies inside the bifrost virtual environment bifrost_venv_dir: "{{ lookup('env', 'VENV') or '/opt/stack/bifrost' }}" +bifrost_venv_env: + VIRTUAL_ENV: "{{ bifrost_venv_dir }}" + PATH: "{{ bifrost_venv_dir }}/bin:{{ ansible_env.PATH }}" # include regular path via lookup env + pydoc: "python -m pydoc" ansible_python_interpreter: "{{ bifrost_venv_dir + '/bin/python3' }}" enable_keystone: false diff --git a/playbooks/roles/bifrost-keystone-client-config/tasks/validate.yml b/playbooks/roles/bifrost-keystone-client-config/tasks/validate.yml index e811e2ac2..f98f41721 100644 --- a/playbooks/roles/bifrost-keystone-client-config/tasks/validate.yml +++ b/playbooks/roles/bifrost-keystone-client-config/tasks/validate.yml @@ -18,19 +18,16 @@ - block: - name: "List bare metal nodes using CLI and clouds.yaml" command: baremetal --debug node list - environment: - OS_CLOUD: "{{ testing_cloud_name }}" + environment: "{{ bifrost_venv_env | combine({'OS_CLOUD': testing_cloud_name }) }}" - name: "List introspection rules using CLI and clouds.yaml" command: baremetal --debug introspection rule list - environment: - OS_CLOUD: "{{ testing_cloud_name }}" + environment: "{{ bifrost_venv_env | combine({'OS_CLOUD': testing_cloud_name }) }}" when: enable_inspector | bool - name: "List services using CLI and clouds.yaml" command: openstack --debug service list - environment: - OS_CLOUD: bifrost-admin + environment: "{{ bifrost_venv_env | combine({'OS_CLOUD': 'bifrost-admin' }) }}" when: - enable_keystone | bool - "'bifrost-admin' in clouds" @@ -42,6 +39,7 @@ baremetal --debug node list args: executable: /bin/bash + environment: "{{ bifrost_venv_env }}" # FIXME(dtantsur): openrc provides no overrides for ironic-inspector, so we # cannot test it. @@ -53,6 +51,7 @@ openstack --debug service list args: executable: /bin/bash + environment: "{{ bifrost_venv_env }}" when: - enable_keystone | bool - "'bifrost-admin' in clouds" diff --git a/releasenotes/notes/validate-path-5c303903900dcd65.yaml b/releasenotes/notes/validate-path-5c303903900dcd65.yaml new file mode 100644 index 000000000..212731c8a --- /dev/null +++ b/releasenotes/notes/validate-path-5c303903900dcd65.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes ``PATH`` to always include the virtual environment when running + validations.