From ec09147988308ccefbc867615740cbc17edcdf50 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 2 Jan 2024 11:58:36 -0700 Subject: [PATCH] Install ansible collections individually Going forward, we can maintain our specific collection requirements in requirements.yml. Signed-off-by: Zack Cerza --- .gitignore | 2 ++ ansible.cfg | 4 ++++ bootstrap | 3 +++ requirements.yml | 12 ++++++++++++ teuthology/task/ansible.py | 5 +++++ 5 files changed, 26 insertions(+) create mode 100644 ansible.cfg create mode 100644 requirements.yml diff --git a/.gitignore b/.gitignore index 19ded7805e..68a366c732 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ docs/teuthology.*.rst # vscode .vscode/ + +.ansible diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000000..c7bd5e20d9 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +# Store collections in this directory. This is to avoid potential compatibility +# issues between differently-versioned ansible processes. +collections_path = .ansible diff --git a/bootstrap b/bootstrap index 96e87f1f2d..5342889992 100755 --- a/bootstrap +++ b/bootstrap @@ -219,3 +219,6 @@ fi # Check to make sure requirements are met ./$VENV/bin/pip check + +# Install ansible collections +./$VENV/bin/ansible-galaxy install -r requirements.yml diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000000..ec47f6713a --- /dev/null +++ b/requirements.yml @@ -0,0 +1,12 @@ +--- +collections: + - amazon.aws + - name: ansible.netcommon + version: "<6.0.0" # 6.0 requires ansible-core >= 2.14 + - ansible.posix + - name: ansible.utils + version: "<3.0.0" # 3.0 requires ansible-core >= 2.14 + - community.docker + - community.general + - community.postgresql + diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index a65a983f6d..d27137d12c 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -3,6 +3,7 @@ import logging import re import requests import os +import pathlib import pexpect import yaml import shutil @@ -354,6 +355,10 @@ class Ansible(Task): environ['ANSIBLE_FAILURE_LOG'] = self.failure_log.name environ['ANSIBLE_ROLES_PATH'] = "%s/roles" % self.repo_path environ['ANSIBLE_NOCOLOR'] = "1" + # Store collections in /.ansible/ + # This is the same path used in /ansible.cfg + environ['ANSIBLE_COLLECTIONS_PATH'] = str( + pathlib.Path(__file__).parents[2] / ".ansible") args = self._build_args() command = ' '.join(args) log.debug("Running %s", command) -- 2.39.5