puppet-openstack-integration/install_modules.sh
Colleen Murphy ec2457a301 Add Puppetfile and install script
This repo will be cloned by the puppet modules and used to install
modules in functional tests. The script uses r10k to deploy modules
from the Puppetfile because this is the Puppet Labs recommended way to
manage puppet environments, and it is a popular method among our users.
We install all modules from git, not the forge, because r10k does not
give us dependency resolution so installing from the forge does not buy
us anything. If the modules have stable branches in git, r10k uses the
stable branch as a ref, otherwise it uses a tag (pinning to a specific
release).

If zuul-cloner is available, the script first installs the external
modules with r10k, then extracts the OpenStack modules from the
Puppetfile to install with zuul-cloner. In the future, this part may be
split out into a JJB job.

Note: because r10k purges the modules directory before installing
modules, and this feature cannot be turned off[1], we must run r10k to
install the external modules before running zuul-cloner to install the
OpenStack modules.

[1] https://github.com/puppetlabs/r10k/issues/172

Change-Id: Ide59ef4bdf53a04957e3593815b7514a0e744e0e
2015-07-02 12:28:56 -07:00

48 lines
1.1 KiB
Bash

#!/bin/bash
set -ex
export SCRIPT_DIR=$(readlink -f "$(dirname $0)")
export PUPPETFILE_DIR=/etc/puppet/modules
install_external() {
PUPPETFILE=${SCRIPT_DIR}/Puppetfile1 r10k puppetfile install -v
}
install_openstack() {
cat > clonemap.yaml <<EOF
clonemap:
- name: '(.*?)/puppet-(.*)'
dest: '/etc/puppet/modules/\2'
EOF
local project_names=$(awk '{ if ($1 == ":git") print $3 }' \
${SCRIPT_DIR}/Puppetfile0 | tr -d "'," | cut -d '/' -f 4- | xargs
)
/usr/zuul-env/bin/zuul-cloner -m clonemap.yaml \
--cache-dir /opt/git \
--zuul-ref $ZUUL_REF \
--zuul-branch $ZUUL_BRANCH \
--zuul-url $ZUUL_URL \
git://git.openstack.org $project_names
}
install_all() {
PUPPETFILE=${SCRIPT_DIR}/Puppetfile r10k puppetfile install -v
}
gem install r10k --no-ri --no-rdoc
# If zuul-cloner is there, have it install modules using zuul refs
if [ -e /usr/zuul-env/bin/zuul-cloner ] ; then
csplit ${SCRIPT_DIR}/Puppetfile /'External modules'/ \
--prefix ${SCRIPT_DIR}/Puppetfile \
--suffix '%d'
install_external
install_openstack
else
install_all
fi
puppet module list