Install roles with ansible-galaxy

Ansible roles aren't really python projects, we shouldn't install them
with pip.

Keeps installing ansible-role-collect-logs with pip as ansible has
trouble loading the plugins from that repo otherwise.

Also moves ansible-role-requirements.yml to
ansible-collections-requirements.yml to make its purpose more clear and
repurposes ansible-role-requirements.yml to list the actual roles
installed.

Change-Id: I0d5f8adc1ce82d94d443ab1ce81eacebba579702
This commit is contained in:
Rafael Castillo 2022-03-31 15:58:29 -07:00
parent 4b4a265296
commit c339bce200
4 changed files with 75 additions and 34 deletions

View File

@ -0,0 +1,34 @@
---
collections:
# FIXME(bogdando): LP#1954761: keep these in sync with:
# https://opendev.org/openstack/tripleo-ci/src/branch/master/zuul.d/base.yaml
- name: ansible.utils
source: https://galaxy.ansible.com
version: 2.4.2
- name: ansible.posix
source: https://galaxy.ansible.com
version: 1.3.0
- name: ansible.netcommon
source: https://galaxy.ansible.com
version: 2.4.0
- name: community.general
source: https://galaxy.ansible.com
version: 4.0.2
- name: community.libvirt
source: https://galaxy.ansible.com
version: 1.0.2
- name: openvswitch.openvswitch
source: https://galaxy.ansible.com
version: 2.0.2
- name: openstack.config_template
source: git+https://opendev.org/openstack/ansible-config_template.git
type: git
- name: openstack.cloud
source: git+https://opendev.org/openstack/ansible-collections-openstack
type: git
- name: tripleo.operator
source: git+https://opendev.org/openstack/tripleo-operator-ansible/
type: git
- name: tripleo.collect_logs
source: git+https://opendev.org/openstack/ansible-role-collect-logs/
type: git

View File

@ -1,22 +1,7 @@
--- ---
collections: - src: git+https://opendev.org/openstack/openstack-ansible-os_tempest.git
# FIXME(bogdando): LP#1954761: keep these in sync with: version: master
# https://opendev.org/openstack/tripleo-ci/src/branch/master/zuul.d/base.yaml name: os_tempest
- name: ansible.utils - src: git+https://opendev.org/openstack/ansible-role-python_venv_build.git
source: https://galaxy.ansible.com version: master
version: 2.4.2 name: python_venv_build
- name: ansible.posix
source: https://galaxy.ansible.com
version: 1.3.0
- name: ansible.netcommon
source: https://galaxy.ansible.com
version: 2.4.0
- name: community.general
source: https://galaxy.ansible.com
version: 4.0.2
- name: community.libvirt
source: https://galaxy.ansible.com
version: 1.0.2
- name: openvswitch.openvswitch
source: https://galaxy.ansible.com
version: 2.0.2

View File

@ -2,13 +2,9 @@ git+https://opendev.org/openstack/tripleo-quickstart-extras/#egg=tripleo-quickst
git+https://opendev.org/openstack/tripleo-ha-utils/#egg=tripleo-ha-utils git+https://opendev.org/openstack/tripleo-ha-utils/#egg=tripleo-ha-utils
# browbeat is no longer supported integrated w/ tq # browbeat is no longer supported integrated w/ tq
#git+https://opendev.org/x/browbeat/#egg=browbeat #git+https://opendev.org/x/browbeat/#egg=browbeat
git+https://opendev.org/openstack/openstack-ansible-os_tempest/#egg=openstack-ansible-os_tempest # TODO(rcastillo): Install ansible-role-collect-log through galaxy
git+https://opendev.org/openstack/ansible-role-python_venv_build/#egg=ansible-role-python_venv_build
git+https://opendev.org/openstack/ansible-config_template/#egg=ansible-config_template
git+https://opendev.org/openstack/ansible-role-collect-logs/#egg=ansible-role-collect-logs git+https://opendev.org/openstack/ansible-role-collect-logs/#egg=ansible-role-collect-logs
git+https://opendev.org/openstack/openstack-tempest-skiplist/#egg=openstack-tempest-skiplist git+https://opendev.org/openstack/openstack-tempest-skiplist/#egg=openstack-tempest-skiplist
git+https://opendev.org/openstack/ansible-collections-openstack/#egg=ansible-collections-openstack.cloud
git+https://opendev.org/openstack/tripleo-operator-ansible/#egg=tripleo-operator-ansible
git+https://opendev.org/openstack/tripleo-ci/#egg=tripleo-ci git+https://opendev.org/openstack/tripleo-ci/#egg=tripleo-ci
# NOTE: tripleo-ansible, tripleo-ipa are required for some jobs # NOTE: tripleo-ansible, tripleo-ipa are required for some jobs
# (including standalone deployed with TLS). # (including standalone deployed with TLS).

View File

@ -102,7 +102,7 @@ fi
# This installs all required collections to quickstart virtualenv # This installs all required collections to quickstart virtualenv
install_ansible_collections_deps(){ install_ansible_collections_deps(){
echo "Installing Ansible Collections dependencies" echo "Installing Ansible Collections dependencies"
# Check if we have collections cloned in CI job # Install ansible-collection collections cloned by CI if available
if [[ -e ~/src/github.com/ansible-collections/ansible.utils ]]; then if [[ -e ~/src/github.com/ansible-collections/ansible.utils ]]; then
echo "Installing collections from local directories" echo "Installing collections from local directories"
ansible-galaxy collection install --force \ ansible-galaxy collection install --force \
@ -113,14 +113,38 @@ install_ansible_collections_deps(){
~/src/github.com/ansible-collections/community.libvirt \ ~/src/github.com/ansible-collections/community.libvirt \
~/src/github.com/ansible-collections/openvswitch.openvswitch \ ~/src/github.com/ansible-collections/openvswitch.openvswitch \
-p $VIRTUAL_ENV/share/ansible/collections -p $VIRTUAL_ENV/share/ansible/collections
else
echo "Installing collections directly from Ansible Galaxy server"
ansible-galaxy collection install --force \
-r ansible-role-requirements.yml \
-p $VIRTUAL_ENV/share/ansible/collections
fi fi
# Use collections already cloned by CI if they're available
OS_COLLECTIONS="ansible-config_template ansible-collections-openstack \
tripleo-operator-ansible"
for COLLECTION_REPO in $OS_COLLECTIONS; do
if [[ -d ~/src/opendev.org/openstack/$COLLECTION_REPO ]]; then
ansible-galaxy collection install --force \
~/src/opendev.org/openstack/$COLLECTION_REPO \
-p $VIRTUAL_ENV/share/ansible/collections
fi
done
# Install collections that weren't caught above from the requirements file
ansible-galaxy collection install \
-r ansible-collection-requirements.yml \
-p $VIRTUAL_ENV/share/ansible/collections
}
install_ansible_roles(){
# Use roles already cloned by CI if they're available
OS_ROLES="openstack-ansible-os_tempest ansible-role-python_venv_build"
for ROLE_REPO in $OS_ROLES; do
if [[ -d ~/src/opendev.org/openstack/$ROLE_REPO ]]; then
ansible-galaxy role install --force \
git+file://$HOME/src/opendev.org/openstack/$ROLE_REPO \
-p $VIRTUAL_ENV/share/ansible/roles
fi
done
ansible-galaxy role install \
-r ansible-role-requirements.yml \
-p $VIRTUAL_ENV/share/ansible/roles
} }
# This creates a Python virtual environment and installs # This creates a Python virtual environment and installs
@ -206,6 +230,8 @@ bootstrap () {
popd popd
echo "Run install_ansible_collections from bootstrap..." echo "Run install_ansible_collections from bootstrap..."
install_ansible_collections install_ansible_collections
echo "Run install_ansible_roles from bootstrap..."
install_ansible_roles
} }
activate_venv() { activate_venv() {