Skip to content

Instantly share code, notes, and snippets.

@antriver
Last active March 3, 2017 17:41
Show Gist options
  • Save antriver/a38e8b18c3e491b5fd5caf1393a98ca4 to your computer and use it in GitHub Desktop.
Save antriver/a38e8b18c3e491b5fd5caf1393a98ca4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Use this:
# export hostname=hello.world.com
# wget -O - https://gist.github.com/antriver/a38e8b18c3e491b5fd5caf1393a98ca4/raw | bash
#
# Use this script on a clean server to setup Puppet and then provision the server
# depending on its hostname. See instructions in README.md for usage.
#
# - Installs git (it already comes with 16.04 though!)
# - Installs puppet (available by default on 16.04)
# - Clones mainifests repo to /var/puppet
# - Runs apply.sh
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
apt-get -y install software-properties-common python-software-properties
# Install git
apt-get -y install git
which git
`which git` --version
if which git >/dev/null; then
echo "git is installed";
else
echo "git isn't installed";
exit 1
fi
# Install puppet
apt-get -y install puppet-common
which puppet
`which puppet` --version
if which puppet >/dev/null; then
echo "puppet is installed";
else
echo "puppet isn't installed";
exit 1
fi
# Clone manifests
mkdir /var/puppet
cd /var/puppet
git clone https://antriver@bitbucket.org/antriver/tmd-puppet.git .
# Set hostname if given
if [ $hostname ]
then
./set-hostname.sh $hostname
fi
# Run puppet apply
./apply.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment