Created
October 24, 2013 10:55
-
-
Save fatmcgav/7135075 to your computer and use it in GitHub Desktop.
Foreman Kickstart script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install | |
<%= @mediapath %> | |
lang en_GB.UTF-8 | |
selinux --permissive | |
keyboard uk | |
skipx | |
<% if @host.ip -%> | |
network --bootproto=static --ip=<%= @host.ip %> --netmask=<%= @host.subnet.mask %> --gateway=<%= @host.subnet.gateway %> --nameserver=<%= @host.subnet.dns_primary %> --hostname=<%= @host %> | |
<% else -%> | |
network --bootproto=dhcp --hostname <%= @host %> | |
<% end -%> | |
rootpw --iscrypted <%= root_pass %> | |
firewall --disabled | |
authconfig --useshadow --enablemd5 | |
timezone Europe/London | |
bootloader --location=mbr --append="nofb quiet splash=quiet" --md5pass=<%= root_pass %> | |
<% if @dynamic -%> | |
%include /tmp/diskpart.cfg | |
<% else -%> | |
<%= @host.diskLayout %> | |
<% end -%> | |
text | |
reboot | |
%packages --excludedocs --nobase | |
ntp | |
wget | |
@Core | |
@Base | |
vim-enhanced | |
<% if @dynamic -%> | |
%pre | |
<%= @host.diskLayout %> | |
<% end -%> | |
%post | |
# redirect output to log file | |
exec >/root/ks-post-anaconda.log 2>&1 | |
# tail the output on 7th console | |
tail -f /root/ks-post-anaconda.log >/dev/tty7 & | |
#changing to VT 3 that we can see whats going on.... | |
/usr/bin/chvt 7 | |
logger "Starting anaconda <%= @host %> postinstall" | |
#update local time | |
echo "updating system time" | |
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "ntp.card.co.uk" %> | |
/usr/sbin/hwclock --systohc | |
echo "setting host file" | |
echo "<%= @host.ip %> <%= @host.name %> <%= @host.shortname %>" >> /etc/hosts | |
# install ACT repos if we can | |
rpm -ivh http://yum.card.co.uk/bootstrap/act-repos-CentOS-latest.x86_64.rpm | |
# import gpg key | |
echo "importing GPG keys" | |
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<%= @host.operatingsystem.major %> | |
rpm --import http://yum.card.co.uk/mrepo/keys/RPM-GPG-KEY-puppetlabs | |
# and add the puppet package | |
echo "installing Puppet client" | |
yum -t -y -e 0 install puppet-3.1.1 | |
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 -%> | |
echo "Running Puppet" | |
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize | |
sync | |
# Inform the build system that we are done. | |
echo "Informing Foreman that we are built" | |
wget -q -O /dev/null --no-check-certificate <%= foreman_url %> | |
echo "Post install tasks completed and Foreman informed..." | |
# All done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment