-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create container to run ansible playbooks from
Create container to run ansible playbooks from. This container is meantto be used for NFV performance test runs using test operator
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
container-images/tcib/base/ansible-tests/ansibleTests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
tcib_envs: | ||
USE_EXTERNAL_FILES: true | ||
tcib_actions: | ||
- run: bash /usr/local/bin/uid_gid_manage {{ tcib_user }} | ||
- run: dnf -y install {{ tcib_packages.common | join(' ') }} && dnf clean all && rm -rf /var/cache/dnf | ||
- run: pip3 install ansible==2.9.27 openstacksdk | ||
- run: cp /usr/share/tcib/container-images/tcib/base/ansible-tests/run_ansible.sh /var/lib/ansible/run_ansible.sh | ||
- run: chmod +x /var/lib/ansible/run_ansible.sh | ||
- run: chown -R ansible:ansible /var/lib/ansible | ||
|
||
tcib_entrypoint: /var/lib/ansible/run_ansible.sh | ||
|
||
tcib_packages: | ||
common: | ||
- gcc | ||
- git | ||
- python3 | ||
- python3-devel | ||
- python3-pip | ||
- python3-setuptools | ||
- libffi-devel | ||
- rsync | ||
|
||
tcib_user: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ansible ALL=(ALL) NOPASSWD: ALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
ANSIBLE_DIR="/var/lib/perf/ansible" | ||
|
||
# Check and set ansible debug verbosity | ||
ANSIBLE_DEBUG="" | ||
if [[ ${POD_DEBUG:-true} == true ]]; then | ||
ANSIBLE_DEBUG="-vvvv" | ||
fi | ||
|
||
# Clone the Ansible repository | ||
git clone "$POD_ANSIBLE_GIT_REPO" "$ANSIBLE_DIR" | ||
|
||
# Handle extra vars file if provided | ||
if [[ -n "${POD_ANSIBLE_FILE_EXTRA_VARS:-}" ]]; then | ||
echo "$POD_ANSIBLE_FILE_EXTRA_VARS" > "$ANSIBLE_DIR/extra_vars.yaml" | ||
ANSIBLE_FILE_EXTRA_VARS_PARAM="-e @$ANSIBLE_DIR/extra_vars.yaml" | ||
fi | ||
|
||
# Handle inventory file if provided | ||
if [[ -n "${POD_ANSIBLE_INVENTORY:-}" ]]; then | ||
echo "$POD_ANSIBLE_INVENTORY" > "$ANSIBLE_DIR/inventory" | ||
fi | ||
|
||
# Install collections if specified | ||
if [[ -n "${POD_INSTALL_COLLECTIONS:-}" ]]; then | ||
ansible-galaxy collection install "$POD_INSTALL_COLLECTIONS" | ||
fi | ||
|
||
# Install collections from requirements.yaml if the file exists | ||
if [[ -f "$ANSIBLE_DIR/requirements.yaml" ]]; then | ||
ansible-galaxy collection install -r "$ANSIBLE_DIR/requirements.yaml" | ||
else | ||
echo "requirements.yaml doesn't exist, skipping requirements installation" | ||
fi | ||
|
||
# Navigate to ansible directory and run playbook | ||
cd "$ANSIBLE_DIR" | ||
ansible-playbook "$POD_ANSIBLE_PLAYBOOK" $ANSIBLE_DEBUG -i $ANSIBLE_DIR/inventory $POD_ANSIBLE_EXTRA_VARS $ANSIBLE_FILE_EXTRA_VARS_PARAM |