From e82731f0f33e4a0b769b971725f4bd81991bd6b2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 16 Sep 2016 15:20:58 -0700 Subject: [PATCH] Run ansible apply test in parallel Change-Id: Ic5b5ef5ca115ca244ebf86079f9b192fbb13fad6 --- tools/apply-test.sh | 3 +-- tools/prep-apply.sh | 1 + tools/test_puppet_apply.sh | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/apply-test.sh b/tools/apply-test.sh index 75aa25dbeb..a0477301d6 100755 --- a/tools/apply-test.sh +++ b/tools/apply-test.sh @@ -63,7 +63,6 @@ sudo mkdir -p /var/run/puppet sudo -E bash -x ./install_modules.sh echo "Running apply test on these hosts:" find applytest -name 'puppetapplytest*.final' -print0 -# TODO: restore the use of "-P $(nproc)" for parallel testing find applytest -name 'puppetapplytest*.final' -print0 | \ - xargs -0 -n 1 -I filearg \ + xargs -0 -P $(nproc) -n 1 -I filearg \ ./tools/test_puppet_apply.sh filearg diff --git a/tools/prep-apply.sh b/tools/prep-apply.sh index a5b24a70df..26b5ab865e 100644 --- a/tools/prep-apply.sh +++ b/tools/prep-apply.sh @@ -72,6 +72,7 @@ sudo mv /tmp/hosts /etc/hosts # of configuring hiera. sudo mkdir -p /opt/system-config sudo ln -sf $(pwd) /opt/system-config/production +sudo -H mkdir -p ~/.ansible/tmp virtualenv --system-site-packages /tmp/apply-ansible-env /tmp/apply-ansible-env/bin/pip install ansible diff --git a/tools/test_puppet_apply.sh b/tools/test_puppet_apply.sh index b6f913b87a..4d095bf2fc 100755 --- a/tools/test_puppet_apply.sh +++ b/tools/test_puppet_apply.sh @@ -15,12 +15,20 @@ # under the License. file=$1 -fileout=${file}.out +fileout=`pwd`/${file}.out +ansible_root=`mktemp -d` +cat > $ansible_root/ansible.cfg < $fileout cat $file > $fileout -sudo /tmp/apply-ansible-env/bin/ansible-playbook -f1 --limit localhost playbooks/remote_puppet_adhoc.yaml -e puppet_environment=production -e manifest=`pwd`/$file -e puppet_noop=true -e puppet_logdest=`pwd`/$fileout +export ANSIBLE_CONFIG=$ansible_root/ansible.cfg +sudo -H -E /tmp/apply-ansible-env/bin/ansible-playbook -f1 --limit localhost playbooks/remote_puppet_adhoc.yaml -e puppet_environment=production -e manifest=`pwd`/$file -e puppet_noop=true -e puppet_logdest=$fileout ret=$? if [ $ret -ne 0 ]; then mv $fileout $fileout.FAILED fi +rm -fr $ansible_root exit $ret