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
This commit is contained in:
Colleen Murphy 2018-04-17 00:35:26 +02:00 committed by Colleen Murphy
parent 39626a1401
commit f10f116f60
3 changed files with 37 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF
clonemap:
- name: '(.*?)/puppet-(.*)'
dest: '/etc/puppet/modules/\2'
dest: '$MODULE_PATH/\2'
- name: '(.*?)/ansible-role-(.*)'
dest: '/etc/ansible/roles/\2'
EOF
@ -80,7 +87,7 @@ sudo mv /tmp/hosts /etc/hosts
sudo mkdir -p /opt/system-config
sudo ln -sf $(pwd) /opt/system-config/production
# Really make sure that the openstack_project module is in the module path
sudo ln -sf /opt/system-config/production/modules/openstack_project /etc/puppet/modules
sudo ln -sf /opt/system-config/production/modules/openstack_project $MODULE_PATH
sudo -H mkdir -p ~/.ansible/tmp
virtualenv --system-site-packages /tmp/apply-ansible-env