Skip to content

Instantly share code, notes, and snippets.

@ohadlevy
Created May 31, 2012 08:23
Show Gist options
  • Save ohadlevy/2841883 to your computer and use it in GitHub Desktop.
Save ohadlevy/2841883 to your computer and use it in GitHub Desktop.
#! /bin/bash
echo "updating system time"
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] %>
<%# we only change hostnames on image based provisioning %>
<% if @host.capabilities.include?(:image) -%>
echo "HOSTNAME=<%= @host %>" >> /etc/sysconfig/network
hostname <%= @host %>
cat > /etc/hosts << EOF
<%= snippets "etc-hosts" %>
EOF
<% end -%>
<%# set ssh root key for debugging, it never works on the first time :-) -%>
<% if @host.params["ssh_debug_key"] -%>
echo <%= @host.params["ssh_debug_key"] %> > /root/.ssh/authorized_keys
<% end -%>
# install EPEL
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
# and add the puppet and ruby-shadow package
yum -t -y -e 0 install puppet
echo "Configuring puppet"
cat > /etc/puppet/puppet.conf << EOF
<%= snippets "puppet.conf" %>
EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 puppet on
# Disable most things. Puppet will activate these if required.
echo "Disabling various system services"
<% %w{autofs gpm sendmail cups iptables ip6tables auditd arptables_jf xfs pcmcia isdn rawdevices hpoj bluetooth openibd avahi-daemon avahi-dnsconfd hidd hplip pcscd restorecond mcstrans rhnsd yum-updatesd}.each do |service| -%>
/sbin/chkconfig --level 345 <%= service %> off 2>/dev/null
<% end -%>
<% if @host.info["classes"].include? "puppet::server" -%>
<%= snippets "master_bootstrap" %>
<% else -%>
/usr/sbin/puppetd #--config /etc/puppet/puppet.conf -o --tags no_such_tag --no-daemonize
<% end -%>
# consider rebooting here instead, as we changed the hostname
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment