From f10f116f6025acc45b661d7b496780fef3c00a36 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 17 Apr 2018 00:35:26 +0200 Subject: [PATCH] Fix puppet config for puppet 4 There are some assumptions made about the puppet config paths that aren't applicable for puppet 4. Configuration, including modules, belongs under /etc/puppetlabs. It's also no longer necessary to fix up the templatedir or server configs in puppet.conf. Change-Id: I3b544b6ce4a96a7a2478522a78402f77ff86a5a5 --- install_modules.sh | 14 ++++++++++++-- install_puppet.sh | 20 ++++++++++++-------- tools/prep-apply.sh | 19 +++++++++++++------ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/install_modules.sh b/install_modules.sh index 5d5acd9c1f..58e399f3be 100755 --- a/install_modules.sh +++ b/install_modules.sh @@ -14,7 +14,17 @@ # License for the specific language governing permissions and limitations # under the License. -MODULE_PATH=`puppet config print modulepath | cut -d ':' -f 1` +export PUPPET_VERSION=${PUPPET_VERSION:-3} + +if [ "$PUPPET_VERSION" == "3" ] ; then + export MODULE_PATH=/etc/puppet/modules +elif [ "$PUPPET_VERSION" == "4" ] ; then + export MODULE_PATH=/etc/puppetlabs/code/modules +else + echo "ERROR: unsupported puppet version $PUPPET_VERSION" + exit 1 +fi + SCRIPT_NAME=$(basename $0) SCRIPT_DIR=$(readlink -f "$(dirname $0)") JUST_CLONED=0 @@ -70,7 +80,7 @@ if [ -z "${!MODULES[*]}" ] && [ -z "${!SOURCE_MODULES[*]}" ] ; then exit 0 fi -MODULE_LIST=`puppet module list --color=false` +MODULE_LIST=`PATH=$PATH:/opt/puppetlabs/bin puppet module list --color=false` # Install modules from source for MOD in ${!SOURCE_MODULES[*]} ; do diff --git a/install_puppet.sh b/install_puppet.sh index 30ee15b2b7..3f63dd511c 100755 --- a/install_puppet.sh +++ b/install_puppet.sh @@ -176,10 +176,12 @@ EOF ln -s /usr/bin/pip /usr/bin/pip-python fi - # Wipe out templatedir so we don't get warnings about it - sed -i '/templatedir/d' /etc/puppet/puppet.conf - # Wipe out server, as we don't have one. - sed -i '/server/d' /etc/puppet/puppet.conf + if [ "$PUPPET_VERSION" == "3" ] ; then + # Wipe out templatedir so we don't get warnings about it + sed -i '/templatedir/d' /etc/puppet/puppet.conf + # Wipe out server, as we don't have one. + sed -i '/server/d' /etc/puppet/puppet.conf + fi } function setup_puppet_ubuntu { @@ -242,10 +244,12 @@ EOF --assume-yes dist-upgrade DEBIAN_FRONTEND=noninteractive apt-get --option 'Dpkg::Options::=--force-confold' \ --assume-yes install -y --force-yes $puppetpkg git $rubypkg - # Wipe out templatedir so we don't get warnings about it - sed -i '/templatedir/d' /etc/puppet/puppet.conf - # Wipe out server, as we don't have one. - sed -i '/server/d' /etc/puppet/puppet.conf + if [ "$PUPPET_VERSION" == "3" ] ; then + # Wipe out templatedir so we don't get warnings about it + sed -i '/templatedir/d' /etc/puppet/puppet.conf + # Wipe out server, as we don't have one. + sed -i '/server/d' /etc/puppet/puppet.conf + fi # ensure the agent is stopped and disabled if [ -f /bin/systemctl ]; then service puppet stop diff --git a/tools/prep-apply.sh b/tools/prep-apply.sh index ffd777e7d5..fc58eafd3e 100644 --- a/tools/prep-apply.sh +++ b/tools/prep-apply.sh @@ -15,19 +15,16 @@ # under the License. ROOT=$(readlink -fn $(dirname $0)/..) -export MODULE_PATH="${ROOT}/modules:/etc/puppet/modules" # MODULE_ENV_FILE sets the list of modules to read from and install and can be # overridden by setting it outside the script. export MODULE_ENV_FILE=${MODULE_ENV_FILE:-modules.env} # PUPPET_MANIFEST sets the manifest that is being tested and can be overridden # by setting it outside the script. export PUPPET_MANIFEST=${PUPPET_MANIFEST:-manifests/site.pp} +export PUPPET_VERSION=${PUPPET_VERSION:-3} export PUPPET_INTEGRATION_TEST=1 -# Remove previously-installed modules -sudo rm -rf /etc/puppet/modules/* - # These arrays are initialized here and populated in modules.env # Array of modules to be installed key:value is module:version. @@ -45,6 +42,16 @@ source $MODULE_ENV_FILE # Install puppet SETUP_PIP=false sudo -E bash -x $ROOT/install_puppet.sh +if [ "$PUPPET_VERSION" == "3" ] ; then + export MODULE_PATH=/etc/puppet/modules +elif [ "$PUPPET_VERSION" == "4" ] ; then + export MODULE_PATH=/etc/puppetlabs/code/modules +else + echo "ERROR: unsupported puppet version $PUPPET_VERSION" + exit 1 +fi +# Remove previously-installed modules +sudo rm -rf $MODULE_PATH/* # Install SOURCE_MODULES sudo -E bash -x $ROOT/install_modules.sh @@ -52,7 +59,7 @@ sudo -E bash -x $ROOT/install_modules.sh cat > clonemap.yaml <