#!/bin/bash -x
# Bootstrap for Ubuntu 16.04 LTS (Xenial)
# This version of the bootstrap file uses the upstream Puppet 4 series from
# Puppetlabs, which differs from Puppet 3.8 series supplied with Ubuntu and
# may break environments that are not prepared for Puppet 4.
(
exec 1> >(logger -s -t user-data) 2>&1

wget -O /tmp/puppetlabs-release.deb https://apt.puppetlabs.com/puppetlabs-release-pc1-`lsb_release -sc`.deb
dpkg -i /tmp/puppetlabs-release.deb

export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get -y upgrade

apt-get install -y puppet-agent ruby ruby-dev zlib1g-dev libxml2-dev gcc make patch gnupg2

update-alternatives --install /usr/bin/puppet puppet /opt/puppetlabs/bin/puppet 1
update-alternatives --install /usr/bin/facter facter /opt/puppetlabs/bin/facter 1
update-alternatives --install /usr/bin/hiera hiera /opt/puppetlabs/bin/hiera 1
update-alternatives --install /usr/bin/mco mco /opt/puppetlabs/bin/mco 1

gem install pupistry --no-ri --no-rdoc
mkdir -p /etc/pupistry
mkdir -p <%= puppetcode %>
cat > /etc/pupistry/settings.yaml << "EOF"
general:
  app_cache: ~/.pupistry/cache
  s3_bucket: <%= s3_bucket %>
  s3_prefix: <%= s3_prefix %>
  gpg_disable: <%= gpg_disable %>
  gpg_signing_key: <%= gpg_signing_key %>
agent:
  puppetcode: <%= puppetcode %>
  access_key_id: <%= access_key_id %>
  secret_access_key: <%= secret_access_key %>
  region: <%= region %>
  proxy_uri: <%= proxy_uri %>
  daemon_frequency: <%= daemon_frequency %>
  daemon_minimal: <%= daemon_minimal %>
  environment: <%= environment %>
EOF
chmod 700 /etc/pupistry/settings.yaml
chmod 700 <%= puppetcode %>
pupistry apply --verbose

)

Split Ubuntu 16.04 templates into two - use of stock OS Puppet (3.8.x) vs Puppetlabs Puppet (4.x)
Split Ubuntu 16.04 templates into two - use of stock OS Puppet (3.8.x) vs Puppetlabs Puppet (4.x)
