Remove global variables from manifest/site.pp

We have one global variable that is used in two places.
By removing it, we can more easily split site.pp into
per-service manifest files, and ultimately we should be
deriving this from groups['elasticsearch'] anyway.

Change-Id: I1d794b269847da85778f71e816359953af9b31e0
This commit is contained in:
Monty Taylor 2020-04-17 13:14:50 -05:00
parent 5468f49254
commit 3e4d99b6fd
2 changed files with 25 additions and 28 deletions

View File

@ -1,22 +1,3 @@
#
# Top-level variables
#
# There must not be any whitespace between this comment and the variables or
# in between any two variables in order for them to be correctly parsed and
# passed around in test.sh
#
# Note we do not do a hiera lookup here as we set $group on a per node basis
# and that must be set before we can do hiera lookups. Doing a hiera lookup
# here would fail to find any group specific info.
$elasticsearch_nodes = [
"elasticsearch02.openstack.org",
"elasticsearch03.openstack.org",
"elasticsearch04.openstack.org",
"elasticsearch05.openstack.org",
"elasticsearch06.openstack.org",
"elasticsearch07.openstack.org",
]
#
# Default: should at least behave like an openstack server
#
@ -225,6 +206,15 @@ node /^logstash\d*\.open.*\.org$/ {
node /^logstash-worker\d+\.open.*\.org$/ {
$group = 'logstash-worker'
$elasticsearch_nodes = [
'elasticsearch02.openstack.org',
'elasticsearch03.openstack.org',
'elasticsearch04.openstack.org',
'elasticsearch05.openstack.org',
'elasticsearch06.openstack.org',
'elasticsearch07.openstack.org',
]
class { 'openstack_project::server': }
class { 'openstack_project::logstash_worker':
@ -250,6 +240,16 @@ node /^subunit-worker\d+\.open.*\.org$/ {
# Node-OS: xenial
node /^elasticsearch\d+\.open.*\.org$/ {
$group = "elasticsearch"
$elasticsearch_nodes = [
'elasticsearch02.openstack.org',
'elasticsearch03.openstack.org',
'elasticsearch04.openstack.org',
'elasticsearch05.openstack.org',
'elasticsearch06.openstack.org',
'elasticsearch07.openstack.org',
]
class { 'openstack_project::server': }
class { 'openstack_project::elasticsearch_node':
discover_nodes => $elasticsearch_nodes,

View File

@ -22,18 +22,15 @@ fi
trap "mv ~/applytest applytest" EXIT
# First split the variables at the beginning of the file
csplit -sf ~/applytest/prep $PUPPET_MANIFEST '/^$/' {0}
# Then split the class defs.
csplit -sf ~/applytest/puppetapplytest ~/applytest/prep01 '/^}$/' {*}
# Split the class defs.
csplit -sf ~/applytest/puppetapplytest $PUPPET_MANIFEST '/^}$/' {*}
# 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*
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/puppetapplytest*
sed -i -e 's@hiera(.\([^.]*\).,\([^)]*\))@\2@' ~/applytest/puppetapplytest*
sed -i -e "s@hiera(.\([^.]*\).)@'\1NoDefault'@" ~/applytest/puppetapplytest*
if [[ `lsb_release -i -s` == 'CentOS' ]]; then
if [[ `lsb_release -r -s` =~ '7' ]]; then
@ -55,7 +52,7 @@ for f in `find ~/applytest -name 'puppetapplytest*' -print` ; do
echo "Skipping $f due to unsupported puppet version"
continue
else
cat ~/applytest/head $f > $f.final
cp $f $f.final
FOUND=1
fi
fi