From: Taseer Date: Mon, 24 Sep 2018 11:13:20 +0000 (+0200) Subject: Remove duplicated parts from Ansible-ODL CI script X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=378961c96ee6a23cb192d0b9a108ee3acd63d97b;p=releng%2Fbuilder.git Remove duplicated parts from Ansible-ODL CI script This patch moves the common parts of the Ansible-ODL CI scripts into one script and adds each of the testing parts as separate builder scripts. JIRA: INTPAK-197 Change-Id: Ic9e887d3c52d1cb78b523b9e1de3f6430f59a18f Signed-off-by: Taseer --- diff --git a/jjb/packaging/ansible.yaml b/jjb/packaging/ansible.yaml index 3b71487e0..d1c7f363f 100644 --- a/jjb/packaging/ansible.yaml +++ b/jjb/packaging/ansible.yaml @@ -44,6 +44,7 @@ build-timeout: '{build-timeout}' builders: + - shell: !include-raw: setup-ansible.sh - shell: !include-raw: test-ansible-rpm.sh - shell: !include-raw: test-ansible-odl-user.sh - shell: !include-raw: test-odl-logs.sh diff --git a/jjb/packaging/setup-ansible.sh b/jjb/packaging/setup-ansible.sh new file mode 100644 index 000000000..eec7cbf03 --- /dev/null +++ b/jjb/packaging/setup-ansible.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Options: +# -x: Echo commands +# -e: Fail on errors +# -o pipefail: Fail on errors in scripts this calls, give stacktrace +set -ex -o pipefail + +# Install required packages +virtualenv rpm_build +source rpm_build/bin/activate +PYTHON="rpm_build/bin/python" +$PYTHON -m pip install --upgrade pip + +# Install Ansible +sudo yum install -y ansible + +# Install local version of ansible-opendaylight to path expected by Ansible. +# Could almost do this by setting ANSIBLE_ROLES_PATH=$WORKSPACE, but Ansible +# expects the dir containing the role to have the name of role. The JJB project +# is called "ansible", which causes the cloned repo name to not match the role +# name "opendaylight". So we need a cp/mv either way and this is simplest. +sudo cp -R $WORKSPACE/ansible /etc/ansible/roles/opendaylight diff --git a/jjb/packaging/test-ansible-odl-user.sh b/jjb/packaging/test-ansible-odl-user.sh index c44c08bb7..7535807fd 100644 --- a/jjb/packaging/test-ansible-odl-user.sh +++ b/jjb/packaging/test-ansible-odl-user.sh @@ -1,11 +1,5 @@ #!/bin/bash -# Options: -# -x: Echo commands -# -e: Fail on errors -# -o pipefail: Fail on errors in scripts this calls, give stacktrace -set -ex -o pipefail - # Create Ansible custom module directories sudo mkdir -p /usr/share/ansible/plugins/modules diff --git a/jjb/packaging/test-ansible-rpm.sh b/jjb/packaging/test-ansible-rpm.sh index 4c769ef5b..df2feb318 100644 --- a/jjb/packaging/test-ansible-rpm.sh +++ b/jjb/packaging/test-ansible-rpm.sh @@ -1,28 +1,4 @@ #!/bin/bash -# Options: -# -x: Echo commands -# -e: Fail on errors -# -o pipefail: Fail on errors in scripts this calls, give stacktrace -set -ex -o pipefail - -# Install required packages -virtualenv rpm_build -source rpm_build/bin/activate -PYTHON="rpm_build/bin/python" -$PYTHON -m pip install --upgrade pip - -# Install Ansible -sudo yum install -y ansible - -# Install local version of ansible-opendaylight to path expected by Ansible. -# Could almost do this by setting ANSIBLE_ROLES_PATH=$WORKSPACE, but Ansible -# expects the dir containing the role to have the name of role. The JJB project -# is called "ansible", which causes the cloned repo name to not match the role -# name "opendaylight". So we need a cp/mv either way and this is simplest. -sudo cp -R $WORKSPACE/ansible /etc/ansible/roles/opendaylight - # Install OpenDaylight via repo using example Ansible playbook sudo ansible-playbook -i "localhost," -c local $WORKSPACE/ansible/examples/rpm_8_devel_odl_api.yml --extra-vars "@$WORKSPACE/ansible/examples/log_vars.json" - -# Add more tests diff --git a/jjb/packaging/test-odl-logs.sh b/jjb/packaging/test-odl-logs.sh index 11dc72ab7..a8cca75c5 100644 --- a/jjb/packaging/test-odl-logs.sh +++ b/jjb/packaging/test-odl-logs.sh @@ -1,10 +1,4 @@ #!/bin/bash -# Options: -# -x: Echo commands -# -e: Fail on errors -# -o pipefail: Fail on errors in scripts this calls, give stacktrace -set -ex -o pipefail - # Execute the test ODL logs playbook sudo ansible-playbook -i "localhost," -c local $WORKSPACE/ansible/tests/test-odl-logs.yaml -v