Skip to content

Commit

Permalink
Create container to run ansible playbooks from
Browse files Browse the repository at this point in the history
Create container to run ansible playbooks from.
This container is meantto be used for NFV
performance test runs using test operator
  • Loading branch information
eshulman2 committed Jun 30, 2024
1 parent b478187 commit 325941a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion container-images/containers.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
container_images:
- imagename: quay.io/podified-master-centos9/openstack-ansible-tests:current-podified
- imagename: quay.io/podified-master-centos9/openstack-aodh-api:current-podified
- imagename: quay.io/podified-master-centos9/openstack-aodh-evaluator:current-podified
- imagename: quay.io/podified-master-centos9/openstack-aodh-listener:current-podified
Expand Down Expand Up @@ -31,7 +32,6 @@ container_images:
- imagename: quay.io/podified-master-centos9/openstack-heat-api:current-podified
- imagename: quay.io/podified-master-centos9/openstack-heat-engine:current-podified
- imagename: quay.io/podified-master-centos9/openstack-horizon:current-podified
- imagename: quay.io/podified-master-centos9/openstack-horizontest:current-podified
- imagename: quay.io/podified-master-centos9/openstack-ironic-api:current-podified
- imagename: quay.io/podified-master-centos9/openstack-ironic-conductor:current-podified
- imagename: quay.io/podified-master-centos9/openstack-ironic-inspector:current-podified
Expand Down
1 change: 1 addition & 0 deletions container-images/kolla/base/uid_gid_manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ _SUPPORTED_USERS['swift']='swift 42445 42445 /var/lib/swift kolla'
_SUPPORTED_USERS['tempest']='tempest 42480 42480 /var/lib/tempest kolla'
_SUPPORTED_USERS['tobiko']='tobiko 42495 42495 /var/lib/tobiko kolla'
_SUPPORTED_USERS['tss']='tss 59 59'
_SUPPORTED_USERS['ansible']='ansible 227 227 /var/lib/ansible kolla'

for _USER_TO_CREATE in $_USERS_TO_CREATE; do
# Initialize computed args
Expand Down
24 changes: 24 additions & 0 deletions container-images/tcib/base/ansible-tests/ansibleTests.yaml
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
1 change: 1 addition & 0 deletions container-images/tcib/base/ansible-tests/ansible_sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible ALL=(ALL) NOPASSWD: ALL
41 changes: 41 additions & 0 deletions container-images/tcib/base/ansible-tests/run_ansible.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -euo pipefail

ANSIBLE_DIR="/var/lib/ansible/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

0 comments on commit 325941a

Please sign in to comment.