Change Netconf Testtool version
[releng/builder.git] / jjb / packaging / setup-ansible-deb.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 deb_build
11 # shellcheck disable=SC1091
12 source deb_build/bin/activate
13 PYTHON="deb_build/bin/python"
14 $PYTHON -m pip install --upgrade pip
15
16 # Wait for any background apt processes to finish
17 # There seems to be a backgroud apt process that locks /var/lib/dpkg/lock
18 # and causes our apt commands to fail.
19 while pgrep apt > /dev/null; do sleep 1; done
20
21 # Install Ansible
22 sudo apt-add-repository ppa:ansible/ansible
23 sudo apt-get update
24 sudo apt-get install -y ansible
25
26 # Install local version of ansible-opendaylight to path expected by Ansible.
27 # Could almost do this by setting ANSIBLE_ROLES_PATH=$WORKSPACE, but Ansible
28 # expects the dir containing the role to have the name of role. The JJB project
29 # is called "ansible", which causes the cloned repo name to not match the role
30 # name "opendaylight". So we need a cp/mv either way and this is simplest.
31 sudo cp -R "$WORKSPACE"/packaging-ansible /etc/ansible/roles/opendaylight