Created
May 12, 2013 07:52
-
-
Save pyKun/5562783 to your computer and use it in GitHub Desktop.
mirantis kickstart file for a cloud node
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 | |
text | |
%include /tmp/source.ks | |
reboot --eject | |
lang en_US.UTF-8 | |
keyboard us | |
rootpw r00tme | |
timezone --utc Etc/UTC | |
zerombr | |
firewall --disabled | |
selinux --disabled | |
%include /tmp/bootloader.ks | |
clearpart --all --initlabel | |
%include /tmp/partition.ks | |
%pre | |
#!/bin/sh | |
# hard drives | |
drives="" | |
for drv in `ls -1 /sys/block | grep "sd\|hd"`; do | |
if (grep -q 0 /sys/block/${drv}/removable); then | |
drives="${drives} ${drv}" | |
fi | |
done | |
set ${drives} | |
numdrives=`echo $#` | |
tgtdrive="undefined" | |
if [ ${numdrives} -gt 1 ]; then | |
exec < /dev/tty3 > /dev/tty3 2>&1 | |
chvt 3 | |
while [ "${tgtdrive}" = "undefined" ]; do | |
clear | |
echo | |
echo '********************************************************************************' | |
echo '* W A R N I N G *' | |
echo '* *' | |
echo '* Which of the detected hard drives do you want to be used as *' | |
echo '* installation target? *' | |
echo '* *' | |
echo '********************************************************************************' | |
echo | |
echo "Possible choices: ${drives}" | |
echo | |
read -p "Choose hard drive: " tgtdrive | |
done | |
clear | |
chvt 1 | |
else | |
tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"` | |
fi | |
# source | |
if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then | |
echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks | |
else | |
echo "cdrom" > /tmp/source.ks | |
fi | |
# bootloader | |
echo "bootloader --location=mbr --driveorder=${tgtdrive}" > /tmp/bootloader.ks | |
# partition | |
echo "partition / --fstype=ext4 --ondisk=${tgtdrive} --size=1 --grow --asprimary" > /tmp/partition.ks | |
echo "partition swap --recommended --ondisk=${tgtdrive}" >> /tmp/partition.ks | |
%end | |
%packages --nobase --excludedocs | |
wget | |
curl | |
crontabs | |
cronie | |
puppet-2.7.19 | |
man | |
yum | |
openssh-clients | |
ntp | |
vim-enhanced | |
authconfig | |
system-config-firewall-base | |
policycoreutils | |
selinux-policy-targeted | |
%post --log=/root/anaconda-post.log | |
#!/bin/sh | |
set -x | |
function setconf { | |
echo | |
echo -n "Enter hostname (FQDN): "; read hostname | |
echo -n "Enter device name: "; read device | |
echo -n "Enter ip: "; read ip | |
echo -n "Enter netmask: "; read netmask | |
echo -n "Enter default gw: "; read gw | |
echo -n "Enter Primary DNS server: "; read dns1 | |
echo -n "Enter Secondary DNS server: "; read dns2 | |
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` | |
echo | |
echo You entered: | |
show | |
echo | |
echo -n "Do you want to keep this settings (y/N):" | |
read -n 1 answer | |
if [[ $answer == "y" || $answer == "Y" ]]; then | |
save_cfg | |
fi | |
echo | |
echo -n "Do you want to configure another adapter (y/N):" | |
read -n 1 answer | |
if [[ $answer == "n" || $answer == "N" || $answer == "" ]]; then | |
endconf=1 | |
fi | |
} | |
function show { | |
echo "Device: $device, MAC address $hwaddr" | |
echo "Hostname: $hostname" | |
[ -z $ip ] && echo "IP address: will be obtained via DHCP" | |
[ ! -z $ip ] && echo "IP address: $ip Netmask: $netmask" | |
echo "Gateway: $gw" | |
echo "DNS Server 1: $dns1" | |
echo "DNS Server 2: $dns2" | |
} | |
function save_cfg { | |
scrFile="/etc/sysconfig/network-scripts/ifcfg-$device" | |
sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network | |
grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts | |
echo GATEWAY=$gw >> /etc/sysconfig/network | |
echo "nameserver 127.0.0.1" > /etc/resolv.conf | |
[ $dns1 ] && echo "nameserver $dns1" > /etc/dnsmasq.upstream | |
[ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream | |
echo DEVICE=$device > $scrFile | |
echo ONBOOT=yes >> $scrFile | |
echo NM_CONTROLLED=no >> $scrFile | |
echo HWADDR=$hwaddr >> $scrFile | |
echo USERCTL=no >> $scrFile | |
echo PEERDNS=no >> $scrFile | |
if [ $ip ]; then | |
echo BOOTPROTO=static >> $scrFile | |
echo IPADDR=$ip >> $scrFile | |
echo NETMASK=$netmask >> $scrFile | |
else | |
echo BOOTPROTO=dhcp >> $scrFile | |
fi | |
} | |
# Default FQDN | |
hostname="nailgun.mirantis.com" | |
for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done | |
hostname=$hostname | |
ip=$ip | |
netmask=$netmask | |
gw=$gw | |
device="eth0" | |
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` | |
# Saving stdin, stdout and stderr file descriptors | |
exec 3<&0 | |
exec 4>&1 | |
exec 5>&2 | |
curTTY=`tty` | |
set +x | |
exec <$curTTY >$curTTY 2>&1 | |
clear | |
endconf=0 | |
show | |
echo -n "Press any key to make changes in network configuration" | |
read -n 1 -t 5 answer | |
if [ $? -gt 128 ]; then | |
save_cfg | |
else | |
while [ $endconf -eq 0 ]; do | |
echo | |
echo -n "Do you want to configure settings manually (y/N):" | |
read -n 1 answer | |
if [[ $answer == "y" || $answer == "Y" ]]; then | |
setconf | |
else | |
endconf=1 | |
fi | |
done | |
fi | |
chvt 1 | |
# Restoring stdin, stdout and stderr file descriptors | |
exec 0<&3 3<&- | |
exec 1>&4 4>&- | |
exec 2>&5 5>&- | |
set -x | |
# Mounting installation source | |
SOURCE=/tmp/source | |
FS=/tmp/fs | |
echo | |
mkdir -p ${SOURCE} | |
mkdir -p ${FS} | |
if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then | |
mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS} | |
mount -o loop ${FS}/nailgun.iso ${SOURCE} | |
else | |
mount /dev/cdrom ${SOURCE} | |
fi | |
# Copying Repo to the nailgun /var/www directory | |
repodir="/var/www/nailgun" | |
mkdir -p ${repodir}/centos/6.3/nailgun/x86_64 | |
cp -r ${SOURCE}/images ${repodir}/centos/6.3/nailgun/x86_64 | |
cp -r ${SOURCE}/isolinux ${repodir}/centos/6.3/nailgun/x86_64 | |
cp -r ${SOURCE}/repodata ${repodir}/centos/6.3/nailgun/x86_64 | |
cp -r ${SOURCE}/Packages ${repodir}/centos/6.3/nailgun/x86_64 | |
cp ${SOURCE}/.treeinfo ${repodir}/centos/6.3/nailgun/x86_64 | |
# Copying eggs/gems to the nailgun directory | |
cp -r ${SOURCE}/eggs ${repodir} | |
cp -r ${SOURCE}/gems ${repodir} | |
# Copying bootstrap image | |
mkdir -p ${repodir}/bootstrap | |
cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap | |
cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap | |
mkdir -p /root/.ssh | |
chmod 700 /root/.ssh | |
cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh | |
chmod 600 /root/.ssh/bootstrap.rsa | |
# Unpacking puppet manifests for master and slave | |
cp ${SOURCE}/puppet-slave.tgz ${repodir}/ | |
mkdir -p /opt/nailgun_puppet | |
tar zxf ${SOURCE}/puppet-nailgun.tgz -C /opt/nailgun_puppet | |
tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules | |
mkdir -p /etc/puppet/manifests/ | |
cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp | |
ln -s /etc/puppet/modules/puppetdb/ /etc/puppet/modules/postgresql/ /etc/puppet/modules/inifile/ /opt/nailgun_puppet/ | |
# Prepare local repository specification | |
rm /etc/yum.repos.d/CentOS*.repo | |
cat > /etc/yum.repos.d/nailgun.repo << EOF | |
[nailgun] | |
name=Nailgun Local Repo | |
baseurl=file:/var/www/nailgun/centos/6.3/nailgun/x86_64 | |
gpgcheck=0 | |
EOF | |
# Disable GSSAPI in ssh server config | |
sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config | |
# Copying bootstrap_admin_node.sh, chmod it and | |
# adding /etc/init/bootstrap_admin_node.conf | |
cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh | |
chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh | |
cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf | |
echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node | |
# Copying version.yaml file. It contains COMMIT_SHA of last commit. | |
mkdir -p /etc/nailgun | |
cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml | |
# Prepare custom /etc/issue logon banner and script for changing IP in it | |
cat > /etc/issue << EOF | |
############################################ | |
# Welcome to the FuelWeb server # | |
############################################ | |
Server is running on \m platform | |
FuelWeb UI is available on: http://:8000 | |
Default administrator login: root | |
Default administrator password: r00tme | |
Please change root password on first login. | |
EOF | |
echo "sed -i \"s%\(^.*able on:\).*$%\1 http://\`ip address show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 -\`:8000%\" /etc/issue" >>/etc/rc.local | |
# Unmounting source | |
umount -f ${SOURCE} | |
rm -rf ${SOURCE} | |
umount -f ${FS} || true | |
rm -rf ${FS} | |
# Enabling/configuring NTPD and ntpdate services | |
echo "server 127.127.1.0" >> /etc/ntp.conf | |
echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf | |
echo "tos orphan 7" >> /etc/ntp.conf | |
chkconfig ntpd on | |
chkconfig ntpdate on | |
# Do not show error message on ntpdate failure. Customers should not be confused | |
# if admin node does not have access to the internet time servers. | |
sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/' | |
# Disabling splash | |
sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf | |
sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf | |
# Disabling console clearing | |
sed -i 's/getty/getty --noclear/' /etc/init/tty.conf | |
# Disabling starting first console from start-ttys service | |
sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init | |
# Copying default bash settings to the root directory | |
cp -f /etc/skel/.bash* /root/ | |
%end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment