Create functions for common bits
* Move out some code from install_modules.sh to have a functions script. * Update install_modules.sh script to use functions. Change-Id: Ie87b8eac71d5edb555e9a1637bea84bc9e268497
This commit is contained in:
parent
2bc07b5a04
commit
acb145de32
70
functions
Normal file
70
functions
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# functions - puppet-openstack-integration specific functions
|
||||||
|
#
|
||||||
|
|
||||||
|
# Install external Puppet modules with r10k
|
||||||
|
# Uses the following variables:
|
||||||
|
#
|
||||||
|
# - ``SCRIPT_DIR`` must be set to script path
|
||||||
|
# - ``GEM_BIN_DIR`` must be set to Gem bin directory
|
||||||
|
install_external() {
|
||||||
|
PUPPETFILE=${SCRIPT_DIR}/Puppetfile1 ${GEM_BIN_DIR}r10k puppetfile install -v
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install Puppet OpenStack modules with zuul-cloner
|
||||||
|
# Uses the following variables:
|
||||||
|
#
|
||||||
|
# - ``PUPPETFILE_DIR`` must be set to Puppet modules directory
|
||||||
|
# - ``SCRIPT_DIR`` must be set to script path
|
||||||
|
# - ``ZUUL_REF`` must be set to Zuul ref
|
||||||
|
# - ``ZUUL_BRANCH`` must be set to Zuul branch
|
||||||
|
# - ``ZUUL_URL`` must be set to Zuul URL
|
||||||
|
install_openstack() {
|
||||||
|
cat > clonemap.yaml <<EOF
|
||||||
|
clonemap:
|
||||||
|
- name: '(.*?)/puppet-(.*)'
|
||||||
|
dest: '$PUPPETFILE_DIR/\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 Puppet modules with r10k
|
||||||
|
# Uses the following variables:
|
||||||
|
#
|
||||||
|
# - ``SCRIPT_DIR`` must be set to script path
|
||||||
|
# - ``GEM_BIN_DIR`` must be set to Gem bin directory
|
||||||
|
install_all() {
|
||||||
|
PUPPETFILE=${SCRIPT_DIR}/Puppetfile ${GEM_BIN_DIR}r10k puppetfile install -v
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install Puppet OpenStack modules and dependencies by using
|
||||||
|
# zuul-cloner or r10k.
|
||||||
|
# Uses the following variables:
|
||||||
|
#
|
||||||
|
# - ``PUPPETFILE_DIR`` must be set to Puppet modules directory
|
||||||
|
# - ``SCRIPT_DIR`` must be set to script path
|
||||||
|
# - ``ZUUL_REF`` must be set to Zuul ref
|
||||||
|
# - ``ZUUL_BRANCH`` must be set to Zuul branch
|
||||||
|
# - ``ZUUL_URL`` must be set to Zuul URL
|
||||||
|
install_modules() {
|
||||||
|
# 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
|
||||||
|
}
|
@ -8,47 +8,13 @@ fi
|
|||||||
|
|
||||||
export SCRIPT_DIR=$(readlink -f "$(dirname $0)")
|
export SCRIPT_DIR=$(readlink -f "$(dirname $0)")
|
||||||
export PUPPETFILE_DIR=${PUPPETFILE_DIR:-/etc/puppet/modules}
|
export PUPPETFILE_DIR=${PUPPETFILE_DIR:-/etc/puppet/modules}
|
||||||
|
source $SCRIPT_DIR/functions
|
||||||
install_external() {
|
|
||||||
PUPPETFILE=${SCRIPT_DIR}/Puppetfile1 ${GEM_BIN_DIR}r10k puppetfile install -v
|
|
||||||
}
|
|
||||||
|
|
||||||
install_openstack() {
|
|
||||||
cat > clonemap.yaml <<EOF
|
|
||||||
clonemap:
|
|
||||||
- name: '(.*?)/puppet-(.*)'
|
|
||||||
dest: '$PUPPETFILE_DIR/\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 ${GEM_BIN_DIR}r10k puppetfile install -v
|
|
||||||
}
|
|
||||||
|
|
||||||
gem install r10k --no-ri --no-rdoc
|
gem install r10k --no-ri --no-rdoc
|
||||||
|
|
||||||
# make sure there is no puppet module pre-installed
|
# make sure there is no puppet module pre-installed
|
||||||
rm -rf "${PUPPETFILE_DIR:?}/"*
|
rm -rf "${PUPPETFILE_DIR:?}/"*
|
||||||
|
|
||||||
# If zuul-cloner is there, have it install modules using zuul refs
|
install_modules
|
||||||
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
|
puppet module list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user