Merge "Make applytest files outside of system-config"
This commit is contained in:
commit
486ebbbe2d
@ -17,21 +17,23 @@
|
|||||||
. ./tools/prep-apply.sh
|
. ./tools/prep-apply.sh
|
||||||
|
|
||||||
if [[ ! -d applytest ]] ; then
|
if [[ ! -d applytest ]] ; then
|
||||||
mkdir applytest
|
mkdir ~/applytest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
trap "mv ~/applytest applytest" EXIT
|
||||||
|
|
||||||
# First split the variables at the beginning of the file
|
# 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.
|
# Then split the class defs.
|
||||||
csplit -sf applytest/puppetapplytest applytest/prep01 '/^}$/' {*}
|
csplit -sf ~/applytest/puppetapplytest ~/applytest/prep01 '/^}$/' {*}
|
||||||
# Remove } header left by csplit
|
# 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.
|
# Comment out anything that doesn't begin with a space.
|
||||||
# This gives us the node {} internal contents.
|
# This gives us the node {} internal contents.
|
||||||
sed -i -e 's/^[^][:space:]$]/#&/g' applytest/prep00 applytest/puppetapplytest*
|
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(.\([^.]*\).,\([^)]*\))@\2@' ~/applytest/prep00 ~/applytest/puppetapplytest*
|
||||||
sed -i -e "s@hiera(.\([^.]*\).)@'\1NoDefault'@" 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
|
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 -i -s` == 'CentOS' ]]; then
|
||||||
if [[ `lsb_release -r -s` =~ '7' ]]; then
|
if [[ `lsb_release -r -s` =~ '7' ]]; then
|
||||||
@ -47,13 +49,13 @@ elif [[ `lsb_release -i -s` == 'Fedora' ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
FOUND=0
|
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 "Node-OS: $CODENAME" $f; then
|
||||||
if grep -q "Puppet-Version: !${PUPPET_VERSION}" $f; then
|
if grep -q "Puppet-Version: !${PUPPET_VERSION}" $f; then
|
||||||
echo "Skipping $f due to unsupported puppet version"
|
echo "Skipping $f due to unsupported puppet version"
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
cat applytest/head $f > $f.final
|
cat ~/applytest/head $f > $f.final
|
||||||
FOUND=1
|
FOUND=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -64,7 +66,7 @@ if [[ $FOUND == "0" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > applytest/primer.pp << EOF
|
cat > ~/applytest/primer.pp << EOF
|
||||||
class helloworld {
|
class helloworld {
|
||||||
notify { 'hello, world!': }
|
notify { 'hello, world!': }
|
||||||
}
|
}
|
||||||
@ -72,7 +74,7 @@ EOF
|
|||||||
|
|
||||||
sudo mkdir -p /var/run/puppet
|
sudo mkdir -p /var/run/puppet
|
||||||
echo "Running apply test primer to avoid setup races when run in parallel."
|
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)
|
THREADS=$(nproc)
|
||||||
if grep -qi centos /etc/os-release ; then
|
if grep -qi centos /etc/os-release ; then
|
||||||
@ -83,7 +85,7 @@ if grep -qi centos /etc/os-release ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Running apply test on these hosts:"
|
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 \
|
xargs -0 -P $THREADS -n 1 -I filearg \
|
||||||
./tools/test_puppet_apply.sh filearg
|
./tools/test_puppet_apply.sh filearg
|
||||||
|
@ -94,6 +94,6 @@ sudo mv /tmp/hosts /etc/hosts
|
|||||||
sudo mkdir -p /opt/system-config
|
sudo mkdir -p /opt/system-config
|
||||||
sudo ln -sf $(pwd) /opt/system-config/production
|
sudo ln -sf $(pwd) /opt/system-config/production
|
||||||
# Really make sure that the openstack_project module is in the module path
|
# 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
|
sudo -H mkdir -p ~/.ansible/tmp
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ elif [ "$PUPPET_VERSION" == "4" ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
file=$1
|
file=$1
|
||||||
fileout=`pwd`/${file}.out
|
fileout=${file}.out
|
||||||
ansible_root=`mktemp -d`
|
ansible_root=`mktemp -d`
|
||||||
cat > $ansible_root/ansible.cfg <<EOF
|
cat > $ansible_root/ansible.cfg <<EOF
|
||||||
[defaults]
|
[defaults]
|
||||||
@ -43,7 +43,7 @@ EOF
|
|||||||
echo "##" > $fileout
|
echo "##" > $fileout
|
||||||
cat $file > $fileout
|
cat $file > $fileout
|
||||||
export ANSIBLE_CONFIG=$ansible_root/ansible.cfg
|
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=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]; then
|
if [ $ret -ne 0 ]; then
|
||||||
mv $fileout $fileout.FAILED
|
mv $fileout $fileout.FAILED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user