Allow blank lines in node{} with apply test

The apply test does some really simple string manipulation to generate
puppet manifests based on our site.pp on the fly. Unfortunately the old
code assumed there would be no blank lines within a node{} definition.
This assumption is breaking as we work to decouple the
openstack_project::server contents from within openstack_project
manifests and move that into site.pp.

This is a relatively simple fix where we csplit nodes based on the
previous /^}$/ which ends the last node{} definition instead of
splitting on blank lines. Added some comments to make what the parsing
does a bit more clear.

Change-Id: I2cc7317ed90423d6f923c4303a76e091a0bc2ebb
This commit is contained in:
Clark Boylan 2015-04-22 13:52:54 -07:00
parent 59be4d7a52
commit 797feda87a
1 changed files with 11 additions and 4 deletions

View File

@ -59,10 +59,17 @@ if [[ ! -d applytest ]] ; then
mkdir applytest
fi
csplit -sf applytest/puppetapplytest manifests/site.pp '/^$/' {*}
sed -i -e 's/^[^][:space:]$]/#&/g' applytest/puppetapplytest*
sed -i -e 's@hiera(.\([^.]*\).,\([^)]*\))@\2@' applytest/puppetapplytest*
mv applytest/*00 applytest/head # These are the top-level variables defined in site.pp
# First split the variables at the beginning of the file
csplit -sf applytest/prep manifests/site.pp '/^$/' {0}
# 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*
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` =~ '6' ]]; then