Skip to content

Commit

Permalink
Install ansible collections individually
Browse files Browse the repository at this point in the history
Going forward, we can maintain our specific collection requirements in
requirements.yml.

Signed-off-by: Zack Cerza <[email protected]>
  • Loading branch information
zmc committed Jan 3, 2024
1 parent 8d1fec2 commit efb3e31
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ docs/teuthology.*.rst

# vscode
.vscode/

.ansible
4 changes: 4 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion containers/teuthology-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && \
lsb-release && \
apt-get clean all
WORKDIR /teuthology
COPY requirements.txt bootstrap /teuthology/
COPY requirements.txt requirements.yml ansible.cfg bootstrap /teuthology/
RUN \
cd /teuthology && \
mkdir ../archive_dir && \
Expand Down
4 changes: 2 additions & 2 deletions docs/docker-compose/teuthology/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN apt-get update && \
lsb-release && \
apt-get clean all
WORKDIR /teuthology
COPY requirements.txt bootstrap /teuthology/
COPY requirements.txt requirements.yml ansible.cfg bootstrap /teuthology/
RUN \
cd /teuthology && \
mkdir ../archive_dir && \
Expand All @@ -40,4 +40,4 @@ RUN \
chmod 600 $HOME/.ssh/${SSH_PRIVKEY_FILE} && \
echo "StrictHostKeyChecking=no" > $HOME/.ssh/config && \
echo "UserKnownHostsFile=/dev/null" >> $HOME/.ssh/config
ENTRYPOINT /teuthology.sh
ENTRYPOINT /teuthology.sh
12 changes: 12 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions teuthology/task/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import requests
import os
import pathlib
import pexpect
import yaml
import shutil
Expand Down Expand Up @@ -354,6 +355,10 @@ def execute_playbook(self, _logfile=None):
environ['ANSIBLE_FAILURE_LOG'] = self.failure_log.name
environ['ANSIBLE_ROLES_PATH'] = "%s/roles" % self.repo_path
environ['ANSIBLE_NOCOLOR'] = "1"
# Store collections in <repo root>/.ansible/
# This is the same path used in <repo root>/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)
Expand Down

0 comments on commit efb3e31

Please sign in to comment.