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
This commit is contained in:
Erik Berg 2022-10-14 15:10:56 +02:00
parent 0329463d77
commit f07628933b
3 changed files with 27 additions and 3 deletions

View File

@ -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)

View File

@ -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

View File

@ -33,7 +33,6 @@ required_packages:
- python3-libselinux
- python3-policycoreutils
- gcc
- python3-pip
- socat
- firewalld
- python3-firewall