blob: 368012926b83d8cd6b95bc70a63965b09b6dc43a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/bash
#
# Deploy configuration using puppet.
#
# Parameters
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."
# Determine hostname
if [ ! -z "$1" ]; then
FQDN="$1"
else
FQDN="`cat /etc/hostname`"
fi
# Set manifest
PUPPET_MANIFEST="$BASEDIR/manifests/nodes/$FQDN.pp"
if [ ! -e "$PUPPET_MANIFEST" ]; then
PUPPET_MANIFEST="$BASEDIR/manifests/nodes/default.pp"
fi
# Check manifest
if [ ! -e "$PUPPET_MANIFEST" ]; then
echo "No manifest found for $FQDN"
exit 1
fi
# Install dependencies
source $DIRNAME/dependencies
# Ensure additional dependencies are installed.
for package in $DEPLOY_DEPENDENCIES; do
provision_package $package
done
# Parameters that needs dependencies installed
DIST="`facter lsbdistcodename`"
# Apply patches
if [ -d "$BASEDIR/puppet/files/patches/$DIST" ]; then
(
# Patches should be generated relativelly to the root folder
cd /
# Only apply if needed
# Thanks https://unix.stackexchange.com/questions/55780/check-if-a-file-or-folder-has-been-patched-already
for patch in `ls $BASEDIR/puppet/files/patches/$DIST`; do
patch -p0 -N --dry-run --silent < $BASEDIR/puppet/files/patches/$DIST/$patch &> /dev/null
# If the patch has not been applied then the $? which is the exit status
# for last command would have a success status code = 0
if [ "$?" == "0" ]; then
# Apply the patch
patch -p0 -N < $BASEDIR/puppet/files/patches/$DIST/$patch
fi
done
)
fi
# Check for Puppetfile
if [ -e "$BASEDIR/Puppetfile" ]; then
if which r10k &> /dev/null; then
( cd $BASEDIR && $SUDO r10k puppetfile install -v )
elif which librarian-puppet &> /dev/null; then
( cd $BASEDIR && $SUDO librarian-puppet install )
fi
fi
# Run puppet apply
PUPPET_OPTS="--confdir=$BASEDIR --modulepath=$BASEDIR/modules"
LC_ALL=C $SUDO puppet apply $PUPPET_OPTS $PUPPET_MANIFEST
|