Skip to content

Commit ccf71c2

Browse files
committed
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
1 parent b478187 commit ccf71c2

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed

container-images/containers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
container_images:
2+
- imagename: quay.io/podified-master-centos9/openstack-ansible-tests:current-podified
23
- imagename: quay.io/podified-master-centos9/openstack-aodh-api:current-podified
34
- imagename: quay.io/podified-master-centos9/openstack-aodh-evaluator:current-podified
45
- imagename: quay.io/podified-master-centos9/openstack-aodh-listener:current-podified
@@ -31,7 +32,6 @@ container_images:
3132
- imagename: quay.io/podified-master-centos9/openstack-heat-api:current-podified
3233
- imagename: quay.io/podified-master-centos9/openstack-heat-engine:current-podified
3334
- imagename: quay.io/podified-master-centos9/openstack-horizon:current-podified
34-
- imagename: quay.io/podified-master-centos9/openstack-horizontest:current-podified
3535
- imagename: quay.io/podified-master-centos9/openstack-ironic-api:current-podified
3636
- imagename: quay.io/podified-master-centos9/openstack-ironic-conductor:current-podified
3737
- imagename: quay.io/podified-master-centos9/openstack-ironic-inspector:current-podified

container-images/kolla/base/uid_gid_manage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ _SUPPORTED_USERS['swift']='swift 42445 42445 /var/lib/swift kolla'
7070
_SUPPORTED_USERS['tempest']='tempest 42480 42480 /var/lib/tempest kolla'
7171
_SUPPORTED_USERS['tobiko']='tobiko 42495 42495 /var/lib/tobiko kolla'
7272
_SUPPORTED_USERS['tss']='tss 59 59'
73+
_SUPPORTED_USERS['ansible']='ansible 227 227 /var/lib/ansible kolla'
7374

7475
for _USER_TO_CREATE in $_USERS_TO_CREATE; do
7576
# Initialize computed args
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
tcib_envs:
2+
USE_EXTERNAL_FILES: true
3+
tcib_actions:
4+
- run: bash /usr/local/bin/uid_gid_manage {{ tcib_user }}
5+
- run: dnf -y install {{ tcib_packages.common | join(' ') }} && dnf clean all && rm -rf /var/cache/dnf
6+
- run: pip3 install ansible==2.9.27 openstacksdk
7+
- run: cp /usr/share/tcib/container-images/tcib/base/ansible-tests/run_ansible.sh /var/lib/ansible/run_ansible.sh
8+
- run: chmod +x /var/lib/ansible/run_ansible.sh
9+
- run: chown -R ansible:ansible /var/lib/ansible
10+
11+
tcib_entrypoint: /var/lib/ansible/run_ansible.sh
12+
13+
tcib_packages:
14+
common:
15+
- gcc
16+
- git
17+
- python3
18+
- python3-devel
19+
- python3-pip
20+
- python3-setuptools
21+
- libffi-devel
22+
- rsync
23+
24+
tcib_user: ansible
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ansible ALL=(ALL) NOPASSWD: ALL
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
ANSIBLE_DIR="/var/lib/ansible/ansible"
6+
7+
# Check and set ansible debug verbosity
8+
ANSIBLE_DEBUG=""
9+
if [[ ${POD_DEBUG:-true} == true ]]; then
10+
ANSIBLE_DEBUG="-vvvv"
11+
fi
12+
13+
# Clone the Ansible repository
14+
git clone "$POD_ANSIBLE_GIT_REPO" "$ANSIBLE_DIR"
15+
16+
# Handle extra vars file if provided
17+
if [[ -n "${POD_ANSIBLE_FILE_EXTRA_VARS:-}" ]]; then
18+
echo "$POD_ANSIBLE_FILE_EXTRA_VARS" > "$ANSIBLE_DIR/extra_vars.yaml"
19+
ANSIBLE_FILE_EXTRA_VARS_PARAM="-e @$ANSIBLE_DIR/extra_vars.yaml"
20+
fi
21+
22+
# Handle inventory file if provided
23+
if [[ -n "${POD_ANSIBLE_INVENTORY:-}" ]]; then
24+
echo "$POD_ANSIBLE_INVENTORY" > "$ANSIBLE_DIR/inventory"
25+
fi
26+
27+
# Install collections if specified
28+
if [[ -n "${POD_INSTALL_COLLECTIONS:-}" ]]; then
29+
ansible-galaxy collection install "$POD_INSTALL_COLLECTIONS"
30+
fi
31+
32+
# Install collections from requirements.yaml if the file exists
33+
if [[ -f "$ANSIBLE_DIR/requirements.yaml" ]]; then
34+
ansible-galaxy collection install -r "$ANSIBLE_DIR/requirements.yaml"
35+
else
36+
echo "requirements.yaml doesn't exist, skipping requirements installation"
37+
fi
38+
39+
# Navigate to ansible directory and run playbook
40+
cd "$ANSIBLE_DIR"
41+
ansible-playbook "$POD_ANSIBLE_PLAYBOOK" $ANSIBLE_DEBUG -i $ANSIBLE_DIR/inventory $POD_ANSIBLE_EXTRA_VARS $ANSIBLE_FILE_EXTRA_VARS_PARAM

0 commit comments

Comments
 (0)