template and postscript for softlayer node install

This commit is contained in:
Bruce Potter 2014-03-02 13:11:41 -05:00
parent c464e3c1d6
commit 9893a2dd71
5 changed files with 150 additions and 6 deletions

View File

@ -62,7 +62,7 @@ sub addKernelParms {
# get node ip and add it to the kernel parms
my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args);
if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; }
$args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway netdevice=$nic netwait=$WAITTIME";
$args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1";
}

View File

@ -14,6 +14,7 @@ use Data::Dumper;
my $HELP;
my $VERBOSE;
my $WAITTIME;
my $NOAUTOINST;
my $usage = sub {
my $exitcode = shift @_;
@ -31,11 +32,11 @@ my $usage = sub {
Getopt::Long::Configure("bundling");
#Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME)) { $usage->(1); }
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); }
if ($HELP) { $usage->(0); }
if (scalar(@ARGV) != 1) { $usage->(1); }
if (!defined($WAITTIME)) { $WAITTIME = 60; } # seconds to wait after configuring the nic (to let the switch handle the state change)
if (!defined($WAITTIME)) { $WAITTIME = 75; } # seconds to wait after configuring the nic (to let the switch handle the state change)
my $noderange = $ARGV[0];
my %bootparms = getBootParms($noderange);
@ -44,7 +45,7 @@ copyFilesToNodes($noderange, \%bootparms);
updateGrubOnNodes($noderange, \%bootparms);
modifyAutoinstFiles($noderange, \%bootparms);
if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); }
exit(0);
@ -61,7 +62,7 @@ sub getBootParms {
my $attr = "bootparams.$a";
@gresults = grep(/^\S+:\s+$attr:/, @output);
if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset <noderange> osimage=<osimage>' ?\n"; }
# for now just pick the 1st one. They should all be the same, except for the node name kcmdline
# for now just pick the 1st one. They should all be the same, except for the node name in kcmdline
chomp($gresults[0]);
$gresults[0] =~ s/^\S+:\s+$attr:\s*//;
$bootparms{$a} = $gresults[0];
@ -140,11 +141,13 @@ sub modifyAutoinstFiles {
my $file = '/mnt/etc/init.d/network'; # at this point in the installation, the permanent file system is just mounted
#my $waitstring = 'echo Sleeping for 55s;sleep 55';
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escape for sed
my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 30 \] \&\& ! ping -c2 -w2 ' . $bootparms->{mnip} .'; do : ; done';
my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 60 \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .'; do echo i=\$xcati ; done; sleep 10';
# this crazy sed string is from google. It gathers up the whole file into the hold buffer, and then the substitution is done on the whole file
my $sedstring = q|sed -n '1h;1!H;${;g;s/\(\t\treload_firewall\n\)\n/\1\t\t| . $waitstring . q(\n\n/g;p;}') . " $file > $file.new";
# finally create the perl replace string that will be used to modify the autoinst file
my $replace = "$sedstring\nchmod 755 $file.new; mv -f $file.new $file";
# now actually update the file
print "Updating /install/autoinst files.\n";
foreach my $n (@nodes) {
my $f = "/install/autoinst/$n";
@ -169,6 +172,16 @@ sub sed {
#verbose('file length is '.length($lines));
close FILE;
# we also need to look for this string 1st
my $replacecopy = $replace; # a search string can't have special chars in it
$replacecopy =~ s/(\W)/\\$1/g; # so escape all of the meta characters
#print "replacecopy=$replacecopy\n";
# check to see if the replace string is already in the file
if ($lines =~ m/$replacecopy/s) {
print "$file did not need updating.\n";
return 1;
}
# search/replace and see if there were any matches
my $matches;
if ($options{mode} eq 'insertbefore') { $matches = $lines =~ s/($search)/\n$replace\n$1/s; }

View File

@ -0,0 +1,6 @@
#!/bin/bash
# set the default route of the node to the ip address and nic passed in
set -x
ip route replace to default via $1 dev $2

View File

@ -0,0 +1,20 @@
#!/bin/sh
# This is modified from the standard xcat post.sles.common in that it does not set up
# the ifcfg-eth0 file to do dhcp and it does not restart the network. It just leaves
# ifcfg-eth0 the way autoyast configured it, assuming we set it statically.
# save what autoyast set network config to, to help with debugging
cp /etc/sysconfig/network/ifcfg-eth0 /tmp/ifcfg-eth0.orig
cp /etc/hosts /tmp/hosts.orig
cp /etc/resolv.conf /tmp/resolv.conf.orig
cp /etc/HOSTNAME /tmp/HOSTNAME.orig
#cd /etc/sysconfig/network
perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config
# autoyast already set hostname correctly
HOSTNAME=$(hostname -s)
echo $HOSTNAME

View File

@ -0,0 +1,105 @@
<?xml version="1.0"?>
<!DOCTYPE profile SYSTEM "/usr/share/YaST2/include/autoinstall/profile.dtd">
<!-- The 2 main differences from the standard xcat compute.sles11.tmpl are:
1. instead of dhcp settings in the networking section it puts static info there
2. it includes post.sles.softlayer.common instead of post.sles11 and post.sles.common -->
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
<install>
<bootloader>
<write_bootloader config:type="boolean">true</write_bootloader>
<activate config:type="boolean">true</activate>
<kernel_parameters></kernel_parameters>
<lba_support config:type="boolean">false</lba_support>
<linear config:type="boolean">false</linear>
<location>mbr</location>
</bootloader>
<general>
<clock>
<hwclock>GMT</hwclock>
<timezone>#TABLE:site:key=timezone:value#</timezone>
</clock>
<keyboard>
<keymap>english-us</keymap>
</keyboard>
<language>en_US</language>
<mode>
<confirm config:type="boolean">false</confirm>
<forceboot config:type="boolean">false</forceboot>
<interactive_boot config:type="boolean">false</interactive_boot>
<reboot config:type="boolean">true</reboot>
</mode>
<mouse>
<id>non</id>
</mouse>
<signature-handling>
<accept_non_trusted_gpg_key config:type="boolean">true</accept_non_trusted_gpg_key>
<accept_unknown_gpg_key config:type="boolean">true</accept_unknown_gpg_key>
<accept_unsigned_file config:type="boolean">true</accept_unsigned_file>
</signature-handling>
</general>
<partitioning config:type="list">
<!-- XCAT-PARTITION-START -->
<drive>
<device>XCATPARTITIONHOOK</device>
<initialize config:type="boolean">true</initialize>
<use>all</use>
</drive>
<!-- XCAT-PARTITION-END -->
</partitioning>
<software>
<patterns config:type="list">
#INCLUDE_DEFAULT_PTRNLIST_S#
</patterns>
<packages config:type="list">
#INCLUDE_DEFAULT_PKGLIST_S#
</packages>
</software>
</install>
<configure>
<users config:type="list">
<user>
<username>root</username>
<user_password>#CRYPT:passwd:key=system,username=root:password#</user_password>
<encrypted config:type="boolean">true</encrypted>
<forename/>
<surname/>
</user>
</users>
<networking>
<keep_install_network config:type="boolean">true</keep_install_network>
<dns>
<domain>#TABLE:site:key=domain:value#</domain>
<hostname>#TABLE:nodelist:$NODE:node#</hostname>
<nameservers config:type="list">
<nameserver>#XCATVAR:XCATMASTER#</nameserver>
</nameservers>
<searchlist config:type="list">
<search>#TABLE:site:key=domain:value#</search>
</searchlist>
</dns>
<routing>
<ip_forward config:type="boolean">false</ip_forward>
</routing>
</networking>
<scripts>
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#
<post-scripts config:type="list">
<script>
<filename>xcat.sh</filename>
<interpreter>shell</interpreter>
<source>
<![CDATA[
#INCLUDE:/root/share/post.sles.softlayer.common#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat#
]]>
</source>
</script>
</post-scripts>
</scripts>
</configure>
</profile>