2014-08-27 11:28:38 -07:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
|
|
|
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2016-05-24 17:40:03 -07:00
|
|
|
. ./tools/prep-apply.sh
|
2014-08-27 11:28:38 -07:00
|
|
|
|
|
|
|
if [[ ! -d applytest ]] ; then
|
|
|
|
mkdir applytest
|
|
|
|
fi
|
|
|
|
|
2015-04-22 13:52:54 -07:00
|
|
|
# First split the variables at the beginning of the file
|
2015-09-22 17:23:21 -07:00
|
|
|
csplit -sf applytest/prep $PUPPET_MANIFEST '/^$/' {0}
|
2015-04-22 13:52:54 -07:00
|
|
|
# Then split the class defs.
|
|
|
|
csplit -sf applytest/puppetapplytest applytest/prep01 '/^}$/' {*}
|
|
|
|
# Remove } header left by csplit
|
|
|
|
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*
|
2015-05-28 14:21:51 -07:00
|
|
|
sed -i -e "s@hiera(.\([^.]*\).)@'\1NoDefault'@" applytest/prep00 applytest/puppetapplytest*
|
2015-04-22 13:52:54 -07:00
|
|
|
mv applytest/prep00 applytest/head # These are the top-level variables defined in site.pp
|
2014-08-27 11:28:38 -07:00
|
|
|
|
|
|
|
if [[ `lsb_release -i -s` == 'CentOS' ]]; then
|
2015-12-04 13:02:35 -08:00
|
|
|
if [[ `lsb_release -r -s` =~ '7' ]]; then
|
2015-07-20 14:28:47 -04:00
|
|
|
CODENAME='centos7'
|
2014-08-27 11:28:38 -07:00
|
|
|
fi
|
2016-03-16 20:15:18 -04:00
|
|
|
elif [[ `lsb_release -i -s` == 'Debian' ]]; then
|
|
|
|
CODENAME=`lsb_release -c -s`
|
2014-08-27 11:28:38 -07:00
|
|
|
elif [[ `lsb_release -i -s` == 'Ubuntu' ]]; then
|
|
|
|
CODENAME=`lsb_release -c -s`
|
2015-07-20 14:19:01 -04:00
|
|
|
elif [[ `lsb_release -i -s` == 'Fedora' ]]; then
|
|
|
|
REL=`lsb_release -r -s`
|
|
|
|
CODENAME="fedora$REL"
|
2014-08-27 11:28:38 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
FOUND=0
|
|
|
|
for f in `find applytest -name 'puppetapplytest*' -print` ; do
|
|
|
|
if grep -q "Node-OS: $CODENAME" $f; then
|
2014-09-03 19:06:12 -07:00
|
|
|
cat applytest/head $f > $f.final
|
|
|
|
FOUND=1
|
2014-08-27 11:28:38 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $FOUND == "0" ]]; then
|
|
|
|
echo "No hosts found for node type $CODENAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-10-07 11:12:00 -07:00
|
|
|
cat > applytest/primer.pp << EOF
|
|
|
|
class helloworld {
|
|
|
|
notify { 'hello, world!': }
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2014-08-27 11:28:38 -07:00
|
|
|
sudo mkdir -p /var/run/puppet
|
2016-10-07 11:12:00 -07:00
|
|
|
echo "Running apply test primer to avoid setup races when run in parallel."
|
|
|
|
./tools/test_puppet_apply.sh applytest/primer.pp
|
2016-09-13 09:46:41 -07:00
|
|
|
|
2014-09-15 11:12:01 -07:00
|
|
|
echo "Running apply test on these hosts:"
|
|
|
|
find applytest -name 'puppetapplytest*.final' -print0
|
2014-08-27 11:28:38 -07:00
|
|
|
find applytest -name 'puppetapplytest*.final' -print0 | \
|
2016-09-16 15:20:58 -07:00
|
|
|
xargs -0 -P $(nproc) -n 1 -I filearg \
|
2015-03-24 11:05:47 -07:00
|
|
|
./tools/test_puppet_apply.sh filearg
|