Make applytest files outside of system-config
We are copying system-config in parallel to a bunch of targets and we're also creating and deleting applytest files. Instead, do the apply test files outside of the dir that's going to get synced in the puppet role. While we're at it, copy don't link the openstack_project module into /etc/puppet/modules, just to be sure. Change-Id: I4bcd8ebd6da8395e77d673ac76f4c41568d810ec
This commit is contained in:
parent
efd3ad59d9
commit
00f30529e3
@ -17,21 +17,23 @@
|
||||
. ./tools/prep-apply.sh
|
||||
|
||||
if [[ ! -d applytest ]] ; then
|
||||
mkdir applytest
|
||||
mkdir ~/applytest
|
||||
fi
|
||||
|
||||
trap "mv ~/applytest applytest" EXIT
|
||||
|
||||
# First split the variables at the beginning of the file
|
||||
csplit -sf applytest/prep $PUPPET_MANIFEST '/^$/' {0}
|
||||
csplit -sf ~/applytest/prep $PUPPET_MANIFEST '/^$/' {0}
|
||||
# Then split the class defs.
|
||||
csplit -sf applytest/puppetapplytest applytest/prep01 '/^}$/' {*}
|
||||
csplit -sf ~/applytest/puppetapplytest ~/applytest/prep01 '/^}$/' {*}
|
||||
# Remove } header left by csplit
|
||||
sed -i -e '/^\}$/d' applytest/puppetapplytest*
|
||||
sed -i -e '/^\}$/d' ~/applytest/puppetapplytest*
|
||||
# Comment out anything that doesn't begin with a space.
|
||||
# This gives us the node {} internal contents.
|
||||
sed -i -e 's/^[^][:space:]$]/#&/g' applytest/prep00 applytest/puppetapplytest*
|
||||
sed -i -e 's@hiera(.\([^.]*\).,\([^)]*\))@\2@' applytest/prep00 applytest/puppetapplytest*
|
||||
sed -i -e "s@hiera(.\([^.]*\).)@'\1NoDefault'@" applytest/prep00 applytest/puppetapplytest*
|
||||
mv applytest/prep00 applytest/head # These are the top-level variables defined in site.pp
|
||||
sed -i -e 's/^[^][:space:]$]/#&/g' ~/applytest/prep00 ~/applytest/puppetapplytest*
|
||||
sed -i -e 's@hiera(.\([^.]*\).,\([^)]*\))@\2@' ~/applytest/prep00 ~/applytest/puppetapplytest*
|
||||
sed -i -e "s@hiera(.\([^.]*\).)@'\1NoDefault'@" ~/applytest/prep00 ~/applytest/puppetapplytest*
|
||||
mv ~/applytest/prep00 ~/applytest/head # These are the top-level variables defined in site.pp
|
||||
|
||||
if [[ `lsb_release -i -s` == 'CentOS' ]]; then
|
||||
if [[ `lsb_release -r -s` =~ '7' ]]; then
|
||||
@ -47,13 +49,13 @@ elif [[ `lsb_release -i -s` == 'Fedora' ]]; then
|
||||
fi
|
||||
|
||||
FOUND=0
|
||||
for f in `find applytest -name 'puppetapplytest*' -print` ; do
|
||||
for f in `find ~/applytest -name 'puppetapplytest*' -print` ; do
|
||||
if grep -q "Node-OS: $CODENAME" $f; then
|
||||
if grep -q "Puppet-Version: !${PUPPET_VERSION}" $f; then
|
||||
echo "Skipping $f due to unsupported puppet version"
|
||||
continue
|
||||
else
|
||||
cat applytest/head $f > $f.final
|
||||
cat ~/applytest/head $f > $f.final
|
||||
FOUND=1
|
||||
fi
|
||||
fi
|
||||
@ -64,7 +66,7 @@ if [[ $FOUND == "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > applytest/primer.pp << EOF
|
||||
cat > ~/applytest/primer.pp << EOF
|
||||
class helloworld {
|
||||
notify { 'hello, world!': }
|
||||
}
|
||||
@ -72,7 +74,7 @@ EOF
|
||||
|
||||
sudo mkdir -p /var/run/puppet
|
||||
echo "Running apply test primer to avoid setup races when run in parallel."
|
||||
./tools/test_puppet_apply.sh applytest/primer.pp
|
||||
./tools/test_puppet_apply.sh ~/applytest/primer.pp
|
||||
|
||||
THREADS=$(nproc)
|
||||
if grep -qi centos /etc/os-release ; then
|
||||
@ -83,7 +85,7 @@ if grep -qi centos /etc/os-release ; then
|
||||
fi
|
||||
|
||||
echo "Running apply test on these hosts:"
|
||||
find applytest -name 'puppetapplytest*.final' -print0
|
||||
find applytest -name 'puppetapplytest*.final' -print0 | \
|
||||
find ~/applytest -name 'puppetapplytest*.final' -print0
|
||||
find ~/applytest -name 'puppetapplytest*.final' -print0 | \
|
||||
xargs -0 -P $THREADS -n 1 -I filearg \
|
||||
./tools/test_puppet_apply.sh filearg
|
||||
|
@ -94,6 +94,6 @@ sudo mv /tmp/hosts /etc/hosts
|
||||
sudo mkdir -p /opt/system-config
|
||||
sudo ln -sf $(pwd) /opt/system-config/production
|
||||
# Really make sure that the openstack_project module is in the module path
|
||||
sudo ln -sf /opt/system-config/production/modules/openstack_project $MODULE_PATH
|
||||
sudo cp -a /opt/system-config/production/modules/openstack_project $MODULE_PATH
|
||||
sudo -H mkdir -p ~/.ansible/tmp
|
||||
|
||||
|
@ -27,7 +27,7 @@ elif [ "$PUPPET_VERSION" == "4" ] ; then
|
||||
fi
|
||||
|
||||
file=$1
|
||||
fileout=`pwd`/${file}.out
|
||||
fileout=${file}.out
|
||||
ansible_root=`mktemp -d`
|
||||
cat > $ansible_root/ansible.cfg <<EOF
|
||||
[defaults]
|
||||
@ -43,7 +43,7 @@ EOF
|
||||
echo "##" > $fileout
|
||||
cat $file > $fileout
|
||||
export ANSIBLE_CONFIG=$ansible_root/ansible.cfg
|
||||
sudo -H -E /tmp/apply-ansible-env/bin/ansible-playbook -i $ansible_root/hosts -f1 playbooks/remote_puppet_adhoc.yaml -e puppet_environment=production -e manifest=`pwd`/$file -e puppet_noop=true -e puppet_logdest=$fileout -e mgmt_puppet_module_dir=$MODULE_PATH
|
||||
sudo -H -E /tmp/apply-ansible-env/bin/ansible-playbook -i $ansible_root/hosts -f1 playbooks/remote_puppet_adhoc.yaml -e puppet_environment=production -e manifest=$file -e puppet_noop=true -e puppet_logdest=$fileout -e mgmt_puppet_module_dir=$MODULE_PATH
|
||||
ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
mv $fileout $fileout.FAILED
|
||||
|
Loading…
Reference in New Issue
Block a user