forked from DSpace/vagrant-dspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet-bootstrap-ubuntu.sh
97 lines (80 loc) · 3.24 KB
/
puppet-bootstrap-ubuntu.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
#
# This bootstraps Puppet & Librarian-Puppet on Ubuntu 12.04 LTS or 14.04LTS.
# Based on the script at: https://github.com/hashicorp/puppet-bootstrap/
#
# However, we've updated it to also install and configure librarian-puppet
# https://github.com/rodjek/librarian-puppet
# We use librarian-puppet to auto-install 3rd party Puppet modules.
#
set -e
# Puppet directory (this is where we want Puppet to be installed & all its main modules)
PUPPET_DIR=/etc/puppet/
# Load up the release information
. /etc/lsb-release
REPO_DEB_URL="http://apt.puppetlabs.com/puppetlabs-release-${DISTRIB_CODENAME}.deb"
# Version of librarian-puppet to install
LIBRARIAN_PUPPET_VERSION=2.2.3
#--------------------------------------------------------------------
# NO TUNABLES BELOW THIS POINT
#--------------------------------------------------------------------
if [ "$(id -u)" -ne "0" ]; then
echo "This script must be run as root." >&2
exit 1
fi
if which puppet > /dev/null 2>&1 -a apt-cache policy | grep --quiet apt.puppetlabs.com; then
echo "Puppet is already installed."
exit 0
fi
# COMMENTED OUT, as we already ran apt-get update prior to this script
# Do the initial apt-get update
#echo "Initial apt-get update..."
#apt-get update >/dev/null
# Install wget if we have to (some older Ubuntu versions)
echo "Installing wget..."
apt-get install -y wget >/dev/null
# Install the PuppetLabs repo
echo "Configuring PuppetLabs repo..."
repo_deb_path=$(mktemp)
wget --output-document="${repo_deb_path}" "${REPO_DEB_URL}" 2>/dev/null
dpkg -i "${repo_deb_path}" >/dev/null
apt-get update >/dev/null
# Install Puppet
echo "Installing Puppet..."
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install puppet >/dev/null
echo "Puppet installed!"
# COMMENTED OUT, as this is handled by our custom "apt-spy2-bootstrap.sh" script
# Install RubyGems for the provider
#echo "Installing RubyGems..."
#if [ $DISTRIB_CODENAME != "trusty" ]; then
# apt-get install -y rubygems >/dev/null
#fi
#gem install --no-ri --no-rdoc rubygems-update
#update_rubygems >/dev/null
# ----------------------------------------------
# Custom for 'vagrant-dspace' & librarian-puppet
# ----------------------------------------------
# Install our custom Puppet config file f
cp /vagrant/puppet.conf $PUPPET_DIR
### Start librarian-puppet installation & initialization
# Install Git
echo "Installing Git..."
apt-get install -y git >/dev/null
echo "Git installed!"
# Ensure Puppet directory exists & the 'librarian-puppet' Puppetfile is copied there.
if [ ! -d "$PUPPET_DIR" ]; then
mkdir -p $PUPPET_DIR
fi
# Install our custom librarian-puppet config file
cp /vagrant/Puppetfile $PUPPET_DIR
# Install 'librarian-puppet' and all third-party modules configured in Puppetfile
if [ "$(gem search -i librarian-puppet)" = "false" ]; then
echo "Installing librarian-puppet..."
gem install --no-ri --no-rdoc librarian-puppet --version $LIBRARIAN_PUPPET_VERSION >/dev/null
echo "librarian-puppet installed!"
echo "Installing third-party Puppet modules (via librarian-puppet)..."
cd $PUPPET_DIR && librarian-puppet install --clean
else
echo "Updating third-party Puppet modules (via librarian-puppet)..."
cd $PUPPET_DIR && librarian-puppet update
fi