Run ansible apply test in parallel

Change-Id: Ic5b5ef5ca115ca244ebf86079f9b192fbb13fad6
This commit is contained in:
James E. Blair 2016-09-16 15:20:58 -07:00
parent d24d96ab4b
commit e82731f0f3
3 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF
[defaults]
local_tmp=$ansible_root/local_tmp
remote_tmp=$ansible_root/remote_tmp
EOF
echo "##" > $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