Add hiera support

This change adds hiera support into the scenarios so we can override
items via the common.yaml heira file if need be. This change adds
support for two environment variables with run_tests.sh.

HIERA_CONFIG - full path to the hiera yaml configuration file
MANAGE_HIERA - used to enable/disable writing out a hiera.yaml config
file

Change-Id: Iad0050e09e0cc610e0eadc00e328151e88eee10e
This commit is contained in:
Alex Schultz 2016-07-13 13:50:17 -06:00
parent f4bd9fda4e
commit 581e13e6b8
4 changed files with 33 additions and 1 deletions

View File

@ -214,6 +214,11 @@ if [ -d /opt/stackviz ]; then
mv /tmp/stackviz $LOG_DIR
fi
# hiera
if [ -d $SCRIPT_DIR/hiera ]; then
mv $SCRIPT_DIR/hiera $LOG_DIR
fi
# Compress all text logs
sudo find $LOG_DIR -iname '*.txt' -type f -execdir gzip -9 {} \+
sudo find $LOG_DIR -iname '*.dat' -type f -execdir gzip -9 {} \+

View File

@ -76,6 +76,26 @@ install_modules() {
fi
}
# Write out basic hiera configuration
#
# Uses the following variables:
# - ``SCRIPT_DIR`` must be set to the dir that contains a /hiera folder to use
# - ``HIERA_CONFIG`` must be set to the hiera config file location
#
configure_hiera() {
cat <<EOF >$HIERA_CONFIG
---
:backends:
- yaml
:yaml:
:datadir: "${SCRIPT_DIR}/hiera"
:hierarchy:
- "%{::operatingsystem}"
- "%{::osfamily}"
- common
EOF
}
is_fedora() {
if [ -f /etc/os-release ]; then
source /etc/os-release

2
hiera/common.yaml Normal file
View File

@ -0,0 +1,2 @@
---
apache::default_vhost: false

View File

@ -17,8 +17,10 @@ export PUPPET_MAJ_VERSION=${PUPPET_MAJ_VERSION:-3}
export SCENARIO=${SCENARIO:-scenario001}
export MANAGE_PUPPET_MODULES=${MANAGE_PUPPET_MODULES:-true}
export MANAGE_REPOS=${MANAGE_REPOS:-true}
export PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --color=false --test --trace"
export SCRIPT_DIR=$(cd `dirname $0` && pwd -P)
export HIERA_CONFIG=${HIERA_CONFIG:-${SCRIPT_DIR}/hiera/hiera.yaml}
export MANAGE_HIERA=${MANAGE_HIERA:-true}
export PUPPET_ARGS="${PUPPET_ARGS} --detailed-exitcodes --color=false --test --trace --hiera_config ${HIERA_CONFIG}"
export DISTRO=$(lsb_release -c -s)
# NOTE(pabelanger): Setup facter to know about AFS mirror.
@ -81,6 +83,9 @@ fi
install_puppet
PUPPET_FULL_PATH=$(which puppet)
if [ "${MANAGE_HIERA}" = true ]; then
configure_hiera
fi
if uses_debs; then
$SUDO apt-get install -y dstat