Merge "Job for testing the ODL user configuration"
[releng/builder.git] / jjb / packaging / test-ansible-odl-user.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 # Install required packages
10 virtualenv rpm_build
11 source rpm_build/bin/activate
12 rpm_build/bin/python -m pip install --upgrade pip
13
14 # Install Ansible
15 sudo yum install -y ansible
16
17 # Install local version of ansible-opendaylight to path expected by Ansible.
18 # Could almost do this by setting ANSIBLE_ROLES_PATH=$WORKSPACE, but Ansible
19 # expects the dir containing the role to have the name of role. The JJB project
20 # is called "ansible", which causes the cloned repo name to not match the role
21 # name "opendaylight". So we need a cp/mv either way and this is simplest.
22 sudo cp -R $WORKSPACE/ansible /etc/ansible/roles/opendaylight
23
24 # Install OpenDaylight via repo using example Ansible playbook
25 sudo ansible-playbook -i "localhost," -c local $WORKSPACE/ansible/examples/rpm_8_devel.yml
26
27 # Create Ansible custom module directories
28 sudo mkdir -p /usr/share/ansible/plugins/modules
29
30 # Copy the custom module to the directory above
31 sudo cp $WORKSPACE/ansible/library/odl_usermod.py /usr/share/ansible/plugins/modules/
32
33 # Execute the tests playnook
34 sudo ansible-playbook -i "localhost," -c local $WORKSPACE/ansible/tests/test-odl-users.yaml -vvv