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.