Skip to content

Instantly share code, notes, and snippets.

@stbenjam stbenjam/kickstart
Last active Jan 2, 2016

Embed
What would you like to do?
#kind: PXELinux
#name: Community Kickstart PXE
#oses:
#- CentOS 5
#- CentOS 6
#- Fedora 16
#- Fedora 17
#- Fedora 18
#- Fedora 19
#- RedHat 5
#- RedHat 6
#- RedHat 7
default linux
label linux
kernel <%= @kernel %>
<% if @host.operatingsystem.name == "Fedora" and @host.operatingsystem.major.to_i > 16 -%>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ks.device=bootif network ks.sendmac
<% elsif @host.operatingsystem.name == "RedHat" and @host.operatingsystem.major.to_i >= 7 -%>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> network ks.sendmac
<% else -%>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=bootif network kssendmac
<% end -%>
<%#
kind: provision
name: Community Kickstart RHEL
oses:
- RedHat 5
- RedHat 6
- RedHat 7
%>
install
<%= @mediapath %>
lang en_US.UTF-8
selinux --enforcing
keyboard us
skipx
network --bootproto <%= @static ? "static --ip=#{@host.ip} --netmask=#{@host.subnet.mask} --gateway=#{@host.subnet.gateway} --nameserver=#{[@host.subnet.dns_primary,@host.subnet.dns_secondary].reject{|n| n.blank?}.join(',')}" : "dhcp" %> --hostname <%= @host %>
rootpw --iscrypted <%= root_pass %>
firewall --<%= @host.operatingsystem.major.to_i >= 6 ? "service=" : "" %>ssh
authconfig --useshadow --passalgo=sha256 --kickstart
timezone UTC
services --disabled 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
<% if @host.operatingsystem.major.to_i <= 6 -%>
repo --name="Extra Packages for Enterprise Linux" --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %>
key --skip
<% end -%>
<% if @host.params['enable-puppetlabs-repo'] && @host.params['enable-puppetlabs-repo'] == 'true' -%>
repo --name=puppetlabs-products --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/products/<%= @host.architecture %>
repo --name=puppetlabs-deps --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/dependencies/<%= @host.architecture %>
<% end -%>
bootloader --location=mbr --append="nofb quiet splash=quiet" <%= grub_pass %>
<% if @dynamic -%>
%include /tmp/diskpart.cfg
<% else -%>
<%= @host.diskLayout %>
<% end -%>
text
reboot
%packages --ignoremissing
yum
dhclient
ntp
wget
@Core
<% if @host.operatingsystem.major.to_i <= 6 -%>
epel-release
puppet
<% end -%>
<% if @host.params['enable-puppetlabs-repo'] && @host.params['enable-puppetlabs-repo'] == 'true' -%>
puppetlabs-release
<% end -%>
<%= "%end\n" if @host.operatingsystem.major.to_i >= 7 %>
<% if @dynamic -%>
%pre
<%= @host.diskLayout %>
<%= "%end\n" if @host.operatingsystem.major.to_i >= 7 %>
<% end -%>
%post --nochroot
exec < /dev/tty3 > /dev/tty3
#changing to VT 3 so that we can see whats going on....
/usr/bin/chvt 3
(
cp -va /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
/usr/bin/chvt 1
) 2>&1 | tee /mnt/sysimage/root/install.postnochroot.log
<%= "%end\n" if @host.operatingsystem.major.to_i >= 7 %>
%post
logger "Starting anaconda <%= @host %> postinstall"
exec < /dev/tty3 > /dev/tty3
#changing to VT 3 so that we can see whats going on....
/usr/bin/chvt 3
(
#update local time
echo "updating system time"
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "0.fedora.pool.ntp.org" %>
/usr/sbin/hwclock --systohc
<%= snippet "redhat_register" %>
# update all the base packages from the updates repository
yum -t -y -e 0 update
# and add the puppet package
yum -t -y -e 0 install puppet
echo "Configuring puppet"
cat > /etc/puppet/puppet.conf << EOF
<%= snippet "puppet.conf" %>
EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 puppet on
/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 %>
# Sleeping an hour for debug
) 2>&1 | tee /root/install.post.log
exit 0
<%= "%end\n" if @host.operatingsystem.major.to_i >= 7 %>
install
url --url http://zpm.bitbin.de/ks/dist/ks-rhel-x86_64-everything-7-beta-7.0
lang en_US.UTF-8
selinux --enforcing
keyboard us
skipx
network --bootproto dhcp --hostname seven.bitbin.de
rootpw --iscrypted XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
firewall --service=ssh
authconfig --useshadow --passalgo=sha256 --kickstart
timezone UTC
services --disabled 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
bootloader --location=mbr --append="nofb quiet splash=quiet"
#kind: ptable
#name: Community Kickstart Disklayout
#oses:
#- CentOS 5
#- CentOS 6
#- Fedora 16
#- Fedora 17
#- Fedora 18
#- Fedora 19
#- RedHat 5
#- RedHat 6
zerombr
clearpart --all --initlabel
autopart
text
reboot
%packages --ignoremissing
yum
dhclient
ntp
wget
@Core
%end
%post --nochroot
exec < /dev/tty3 > /dev/tty3
#changing to VT 3 so that we can see whats going on....
/usr/bin/chvt 3
(
cp -va /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
/usr/bin/chvt 1
) 2>&1 | tee /mnt/sysimage/root/install.postnochroot.log
%end
%post
logger "Starting anaconda seven.bitbin.de postinstall"
exec < /dev/tty3 > /dev/tty3
#changing to VT 3 so that we can see whats going on....
/usr/bin/chvt 3
(
#update local time
echo "updating system time"
/usr/sbin/ntpdate -sub 0.fedora.pool.ntp.org
/usr/sbin/hwclock --systohc
# Red Hat Registration Snippet
#
# Usage, set these params:
# spacewalk_type = "site" (local Spacewalk/Satellite server)
# = "hosted" (RHN hosted)
# spacewalk_host = <hostname> (hostname of Spacewalk server, optional for
# RHN hosted)
# activation_key = <key> (activation key string)
#
# Discovered Activation Key 1-4eea598d64e18d78d17fe80195777c2d
rhn_activation_key="XXXXXXXX"
satellite_hostname="zpm.bitbin.de"
rhn_cert_file="RHN-ORG-TRUSTED-SSL-CERT"
echo "Registering to RHN Satellite at [$satellite_hostname]"
echo "Using Registration Key [$rhn_activation_key]"
# Obtain our RHN Satellite Certificate
echo "Obtaining RHN SSL certificate"
wget http://$satellite_hostname/pub/$rhn_cert_file -O /usr/share/rhn/$rhn_cert_file
# Update our up2date configuration file
echo "Updating SSL CA Certificate to /usr/share/rhn/$rhn_cert_file"
sed -i -e "s|^sslCACert=.*$|sslCACert=/usr/share/rhn/$rhn_cert_file|" /etc/sysconfig/rhn/up2date
# Update our Satellite Hostname
echo "Updating Satellite Hostname to [$satellite_hostname]"
sed -i -e "s|^serverURL=.*$|serverURL=https://$satellite_hostname/XMLRPC|" /etc/sysconfig/rhn/up2date
sed -i -e "s|^noSSLServerURL=.*$|noSSLServerURL=https://$satellite_hostname/XMLRPC|" /etc/sysconfig/rhn/up2date
# Restart messagebus/HAL to try and prevent hardware detection errors in rhnreg_ks
echo "Restarting services..."
service messagebus restart
service hald restart
# Now, perform our registration
# (might get hardware errors here, due to dbus/messagebus lameness. These are safe to ignore.)
echo -n "Performing RHN Registration... "
rhnreg_ks --activationkey=$rhn_activation_key
echo "done."
# Check we registered
echo -n "Checking System Registration... "
if ! rhn_check; then
echo "FAILED"
echo " >> RHN Registration FAILED. Please Investigate. <<"
else
echo "registration successful."
fi
# Done!
# End Red Hat Registration Snippet
# update all the base packages from the updates repository
yum -t -y -e 0 update
# and add the puppet package
yum -t -y -e 0 install puppet
echo "Configuring puppet"
cat > /etc/puppet/puppet.conf << EOF
#kind: snippet
#name: puppet.conf
[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = \$vardir/ssl
[agent]
pluginsync = true
report = true
ignoreschedules = true
daemon = false
ca_server =
certname = seven.bitbin.de
environment = production
server = gatebuilder.bitbin.de
EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 puppet on
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server gatebuilder.bitbin.de --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 http://gatebuilder.bitbin.de/unattended/built
# Sleeping an hour for debug
) 2>&1 | tee /root/install.post.log
exit 0
%end
#kind: PXELinux
#name: Community Kickstart PXE
#oses:
#- CentOS 5
#- CentOS 6
#- Fedora 16
#- Fedora 17
#- Fedora 18
#- Fedora 19
#- RedHat 5
#- RedHat 6
default linux
label linux
kernel boot/RedHat-7.0-x86_64-vmlinuz
append initrd=boot/RedHat-7.0-x86_64-initrd.img ks=http://gatebuilder.bitbin.de/unattended/provision network ks.sendmac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.