Skip to content

Instantly share code, notes, and snippets.

@psalaberria002
Created September 30, 2015 20:29
Show Gist options
  • Save psalaberria002/d90e923be0745b52cc26 to your computer and use it in GitHub Desktop.
Save psalaberria002/d90e923be0745b52cc26 to your computer and use it in GitHub Desktop.
#!/bin/bash
################INSTALLING PUPPET AGENT#############################
# Variables to change:
# - MASTER_HOSTNAME
# - AGENT_NAME
# - AGENT_HOST
####################################################################
set -e -x
#Updating hostname
MASTER_HOSTNAME=puppetmaster.xxx.com
AGENT_NAME=puppetagentchangeme
AGENT_HOST=xxx.com
AGENT_HOSTNAME="$AGENT_NAME.$AGENT_HOST"
hostname $AGENT_HOSTNAME
echo $AGENT_HOSTNAME > /etc/hostname
new_entry="$AGENT_HOSTNAME $AGENT_NAME localhost"
sed -i "0,/localhost/s//$new_entry/" /etc/hosts
service hostname start
#Installing puppet
export DEBIAN_FRONTEND=noninteractive
#Upgrade facter to latest. (ec2 facts in VPC not working in facter 1.7.5)
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
dpkg -i puppetlabs-release-trusty.deb
# avoid puppet updates higher than specific version
echo "
Package: puppet puppet-common puppetmaster puppetmaster-common
Pin: version 3.7*
Pin-Priority: 501" > /etc/apt/preferences.d/00-puppet.pref
sudo apt-get update
apt-get -y install facter
aptitude -y install puppet
#Create/edit puppet.conf
echo "
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
server=$MASTER_HOSTNAME
[agent]
report=true
show_diff=true
" > /etc/puppet/puppet.conf
#enable puppet
sed -i /etc/default/puppet -e 's/START=no/START=yes/'
puppet agent --enable
service puppet restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment