I don’t know if this is possible, but going to ask anyways.
I am trying to Kickstart newer servers of us with CentOS 7. So far I got most working, however for some reason if I use variables in the %pre section of my Kickstart script, then it does not get parsed over to the configuration at all. Therefor I am starting to think this is not even possible?
This is what I have in the %pre section of my Kickstart:
%pre --log /tmp/pre-install.log hostname=serverA120 ip=100.110.120.130 IFS=. read ip1 ip2 ip3 ip4 <<< "$ip"
Than during the Kickstart it should use the above filled-in information:
network --bootproto=static --device=eth0 --gateway=100.110.$ip3.1 --ip=$ip --nameserver=220.127.116.11 --netmask=255.255.255.0 network --hostname=$hostname.example.com
And in the %post section I also try to use the variables from %pre:
sed -i'' -e '/HOSTNAME=/d' /etc/sysconfig/network echo HOSTNAME=$hostname.example.com >> /etc/sysconfig/network echo GATEWAY=100.110.$ip3.1 >> /etc/sysconfig/network echo BOOTPROTO=static >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo IPADDR=$ip >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo NETMASK=255.255.255.0 >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo BROADCAST=100.110.$ip3.255 >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo NETWORK=100.110.$ip3.0 >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo GATEWAY=100.110.$ip3.1 >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo $hostname.example.com >> /etc/hostname sudo hostnamectl set-hostname $hostname.example.com
I checked the ifcfg-eth0 physically after I couldn’t reach the server anymore and it showed the following:
IPADDR= BROADCAST=100.110..255 NETWORK=100.110..0 GATEWAY=100.110..1
I also checked /etc/hostname:
So variables are not being parsed into the Kickstart. Am I doing something wrong or is it simply not possible? And is there an alternative solution perhaps for this?
Ofcourse I can manually adjust all lines manually before and after, but I wanted to make this as easy as possible without editing everything manually. In other words, I just want to fill in 2 lines and that rest gets configured as I want. This would make things easier with Kickstarting multiple servers on the long run.
I have no clue what I am doing wrong, but checking ifcfg-eth0 and hostname, it clearly shows the pre-entered variables are not being used? But like I said above, maybe it’s simply not possible, that or I am using it incorrectly.
And no I don’t want to use DHCP or similar. Because I still have to change it manually afterwards. I just want to fill in the first two lines in %pre (hostname and ip) and that it gets used automatically during the complete installation (and in %post).