From f07628933bc906c59a462beae4a0515438e2e5a3 Mon Sep 17 00:00:00 2001 From: Erik Berg Date: Fri, 14 Oct 2022 15:10:56 +0200 Subject: [PATCH] Fix initial python/venv dependencies If you're running 'ansible-playbook -i inventory/target install.yaml' install python3-pip on the system as early as possible. We need to set ansible_python_interpreter to the system, because some roles set it to {{ bifrost_venv_dir }}/bin/python3, which doesn't necessarily exist at this moment. We can now create a venv, and override ansible_python_interpreter Change-Id: Iee5125c61151f01538371f4140cd5321ab509bba --- playbooks/install.yaml | 27 +++++++++++++++++++ .../required_defaults_Debian_family.yml | 2 -- .../required_defaults_RedHat_family.yml | 1 - 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/playbooks/install.yaml b/playbooks/install.yaml index a0cdd6b32..dcb0032d5 100644 --- a/playbooks/install.yaml +++ b/playbooks/install.yaml @@ -3,6 +3,33 @@ name: "Install Ironic on the target host." become: yes gather_facts: yes + vars: + bifrost_venv_dir: "{{ lookup('env', 'VENV') or '/opt/stack/bifrost' }}" + ansible_python_interpreter: "/usr/bin/env python3" + pre_tasks: + - name: install pip (and venv) to system + package: + name: "{{ packages | select | list }}" + vars: + packages: + - python3-pip + - "{{ (ansible_facts['os_family'] == 'Debian') | ternary('python3-venv', '') }}" + + - name: create venv + command: python3 -m venv {{ bifrost_venv_dir }} + args: + creates: "{{ bifrost_venv_dir }}/bin/python3" + + # NOTE(ebbex): (incase it's missing, which it shouldn't normally be) + - name: install setuptools in venv + command: "{{ bifrost_venv_dir }}/bin/pip3 install setuptools" + args: + creates: "{{ bifrost_venv_dir }}/lib/python*/site-packages/setuptools" + + - name: override ansible_python_interpreter to venv + set_fact: + ansible_python_interpreter: "{{ bifrost_venv_dir + '/bin/python3' }}" + roles: - role: bifrost-prep-for-install when: not (skip_install | default(false) | bool) diff --git a/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_Debian_family.yml b/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_Debian_family.yml index c6f50e733..3bff349a8 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_Debian_family.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_Debian_family.yml @@ -15,7 +15,6 @@ required_packages: - python3-dev - python3-mysqldb - python3-pymysql - - python3-setuptools - libffi-dev - libxslt1-dev - libssl-dev @@ -33,7 +32,6 @@ required_packages: - uuid-runtime - curl - socat - - python3-pip - gcc - dnsmasq - apache2-utils diff --git a/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_RedHat_family.yml b/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_RedHat_family.yml index bf923a214..e8f467270 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_RedHat_family.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/required_defaults_RedHat_family.yml @@ -33,7 +33,6 @@ required_packages: - python3-libselinux - python3-policycoreutils - gcc - - python3-pip - socat - firewalld - python3-firewall