I have scripts in my kickstart profile that allows me to customize the server 
and it registers with spacewalk with the correct name then. This works with 
text install and uses the current terminal anaconda is using. Haven't tested 
with GUI install. 

Allows config of hostname, network bonding, and can be expanded for any other 
configuration variables needed. Simply asks all inputs at the beginning and 
transfers variables into chroot environment to be used by post install scripts 
to finsh configuring the server. Not the prettiest script but it works.

Make sure to add "%include /tmp/network" without quotes to Kickstart > profile> 
advanced options tab > Custom Options.

Pre Script:
#########################################################################################
curTTY=`tty`
exec < $curTTY > $curTTY 2> $curTTY

echo
echo -n "Starting Pre Install Script"

echo
echo -n "Configure the Server"

hwaddr3=`ifconfig eth1 | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
hwaddr2=`ifconfig eth0 | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
dns1="10.x.x.x"
dns2="10.x.x.x"
device3="eth1"
device2="eth0"
device1="bond0"
gw=""
answer="n"
hostname2=""
netmask=""
ip=""

while [ x"$answer" != "xy" ] && [ x"$answer" != "xY" ]; do
        echo
        echo -n "enter hostname: "; read hostname2
        echo -n "enter ip adress: "; read ip
        echo -n "enter netmask: "; read netmask
        echo -n "enter default gateway: "; read gw
        echo

        echo You entered:
        echo -e "\thostname:            $hostname2"
        echo -e "\tip address:          $ip"
        echo -e "\tnetmask:             $netmask"
        echo -e "\tdefault gateway:     $gw"
        echo
        echo -n "Is this correct? [y/n] "; read answer
done

echo
echo -n "Setting Host Name to $hostname2"

echo "network --device eth0 --bootproto dhcp --hostname=${hostname2} 
--onboot=yes --noipv6" > /tmp/network

cat <<EOF > /tmp/variables
hostname2=$hostname2
ip=$ip
netmask=$netmask
gw=$gw
hwaddr3=$hwaddr3
hwaddr2=$hwaddr2
dns1=$dns1
dns2=$dns2
device3=$device3
device2=$device2
device1=$device1
EOF
#########################################################################################

Post Script: nochroot option checked.
#########################################################################################
cp /tmp/variables /mnt/sysimage/tmp/
#########################################################################################

Post Script:
#########################################################################################
curTTY=`tty`
exec < $curTTY > $curTTY 2> $curTTY

echo
echo -n "Starting Post Install Script"
. ./tmp/variables

echo
echo -n "Configuring the Server"
rhn-actions-control --enable-all
rhncfg-client get
rhn_check
sleep 5s

echo
echo -n "setting hostname"
sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname2"'#' /etc/sysconfig/network

echo
echo -n "configuring networking"
echo "alias bond0 bonding" > /etc/modprobe.d/bonding.conf

cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$device2
DEVICE=$device2
BOOTPROTO=none
ONBOOT=yes
NM_Controlled=no
MASTER=$device1
SLAVE=yes
USERCTL=no
TYPE=Ethernet
IPV6INIT=no
HWADDR=$hwaddr2
EOF

cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$device3
DEVICE=$device3
BOOTPROTO=none
ONBOOT=yes
NM_Controlled=no
MASTER=$device1
SLAVE=yes
USERCTL=no
TYPE=Ethernet
IPV6INIT=no
HWADDR=$hwaddr3
EOF

cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$device1
DEVICE=$device1
BOOTPROTO=none
ONBOOT=yes
NM_Controlled=no
PEERDNS=yes
DEFROUTE=yes
USERCTL=no
BONDING_OPTS="mode=balance-alb miimon=100"
TYPE=Ethernet
IPV6INT=no
IPADDR=$ip
NETMASK=$netmask
GATEWAY=$gw
DNS1=$dns1
DNS2=$dns2
DOMAIN=teamfreeze.com
EOF

echo root:      [email protected] >> /etc/aliases
newaliases
sysctl -w vm.max_map_count=131072

echo
echo -n "updating inittab to runlevel 3"
sed -i -e 's#^\(id:\).*$#\1'"3:initdefault:"'#' /etc/inittab

rm -rf /tmp/variables

touch /.autorelabel
echo "rhn-profile-sync" >> /etc/rc.local

echo
echo -n "Script Complete"
echo
read -p "Press Enter key to reboot..."
#########################################################################################

------------------------------

Message: 3
Date: Thu, 8 May 2014 11:32:47 +0100
From: "Francisco Manuel Cardoso" <[email protected]>
To: <[email protected]>
Subject: [Spacewalk-list] Kickstart Profiles and Naming
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hello,

 

After a bit of a rough patch implementing and getting used to the new 2 
"interface" im left with a question.

When kickstating machines it seems to be possible to make them register to 
spacewalk on "boot", is there a way I can assign a pool of hostnames to the 
profiles so that they come out named and "in order" ?

 

Cheers

 

Francisco


_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to