Skip to content

Instantly share code, notes, and snippets.

@amartinj
Created October 5, 2012 12:20
Show Gist options
  • Save amartinj/3839513 to your computer and use it in GitHub Desktop.
Save amartinj/3839513 to your computer and use it in GitHub Desktop.
Script to install puppet agent and set up basic network setup in debian/ubuntu
#!/bin/sh
if [ "$#" -lt 4 ]
then
echo "Usage: $0 <node_ip> <node_name> <puppet_server_ip> <company.fqdn.com>"
exit 1
fi
PUPPET_HOST=$3
NODE_IP=$1
NODE_NAME=$2
ORG_QN=$4
NETWORK=`echo $NODE_IP | cut -d'.' -f1-3`.0
GATEWAY=`echo $NODE_IP | cut -d'.' -f1-3`.1
BROADCAST=`echo $NODE_IP | cut -d'.' -f1-3`.255
echo "Adding entries to /etc/hosts"
echo "$PUPPET_HOST puppet.$ORG_QN puppet" > /etc/hosts
echo "$NODE_IP $NODE_NAME.$ORG_QN $NODE_NAME" >> /etc/hosts
echo "Setting hostname"
echo "$NODE_NAME" > /etc/hostname
hostname $NODE_NAME
echo "Setting basic network config"
echo "auto lo" > /etc/network/interfaces
echo "iface lo inet loopback" >> /etc/network/interfaces
echo "auto eth0" >> /etc/network/interfaces
echo "iface eth0 inet static" >> /etc/network/interfaces
echo " address $NODE_IP" >> /etc/network/interfaces
echo " netmask 255.255.255.0" >> /etc/network/interfaces
echo " network $NETWORK" >> /etc/network/interfaces
echo " broadcast $BROADCAST" >> /etc/network/interfaces
echo " gateway $GATEWAY" >> /etc/network/interfaces
echo " dns-nameservers 8.8.8.8" >> /etc/network/interfaces
echo " dns-search $ORG_QN" >> /etc/network/interfaces
/etc/init.d/networking restart
echo "Adding puppetlabs source to APT"
echo "deb http://apt.puppetlabs.com/ lucid main" > /etc/apt/sources.list.d/puppet.list
echo "deb-src http://apt.puppetlabs.com/ lucid main" >> /etc/apt/sources.list.d/puppet.list
apt-key adv --keyserver keyserver.ubuntu.com --recv 4BD6EC30
aptitude update
echo "Installing puppet"
apt-get install puppet facter
echo "START=yes" > /etc/default/puppet
echo 'DAEMON_OPTS=""' >> /etc/default/puppet
puppet agent --no-daemonize --verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment