Ian Wienand 7e9229c86d
bootstrap-bridge: drop pip3 role, add venv
The pip3 role installs the latest upstream pip, overwriting the
packaged versions.  We would prefer to install things in
venv/virtualenvs moving forward to keep better isolation.

Unfortunately thanks to time the Bionic era packaged pip is so old
that it can't install anything modern like Ansible.  Thus we have to
squash installing Ansible into a separate venv into this change as
well.

Although the venv created by default on the Bionic host also has an
old pip, luckily we already worked around that in
I81fd268a9354685496a75e33a6f038a32b686352 which provides a create-venv
role that creates a fully updated venv for us.

To minimise other changes, this symlinks ansible/ansible-playbook into
/usr/local/bin.  On our current production bastion host this will make
a bit of a mess -- but we are looking at replacing that with a fresh
system soon.  The idea is that this new system will not be
bootstrapped with a globally installed Ansible, so we won't have
things lying around in multiple places.

Change-Id: I7551eb92bb6dc5918c367cc347f046ff562eab0c
2022-10-11 15:09:40 +11:00

34 lines
1.4 KiB
YAML

# If ansible_install_ansible_ara_version is not defined it should be "latest"
- name: Set ara default version to latest
set_fact:
install_ansible_ara_version: latest
when: install_ansible_ara_version is not defined
# If a version is not explicitly set we want to make sure to
# completely omit the version argument to pip, as it will be coming
# from the long-form install_ansible_ara_name variable. Additionally,
# if the version is the special value "latest", then we also want to
# omit any version number, but also set the package state to "latest".
- name: Set ARA version for installation
set_fact:
_install_ansible_ara_version: '{{ install_ansible_ara_version }}'
when: install_ansible_ara_version not in ('', 'latest')
- name: Set ARA package state for installation
set_fact:
_install_ansible_ara_state: latest
when: install_ansible_ara_version == 'latest'
- name: Install ARA
pip:
name: '{{ install_ansible_ara_name | default("ara[server]") }}'
version: '{{ _install_ansible_ara_version | default(omit) }}'
state: '{{ _install_ansible_ara_state | default(omit) }}'
virtualenv: '/usr/ansible-venv'
# For configuring the callback plugins location in ansible.cfg
- name: Get ARA's location for callback plugins
command: /usr/ansible-venv/bin/python3 -m ara.setup.callback_plugins
register: install_ansible_ara_callback_plugins
changed_when: false