{"id":181,"date":"2010-08-18T11:34:56","date_gmt":"2010-08-18T17:34:56","guid":{"rendered":"http:\/\/benincosa.com\/blog\/?p=181"},"modified":"2014-11-19T11:25:59","modified_gmt":"2014-11-19T17:25:59","slug":"esxi-4-1-kickstart-on-xcat","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=181","title":{"rendered":"ESXi 4.1 Kickstart on xCAT"},"content":{"rendered":"<p>I recently added the ESXi 4.1 base template kickstart file to xCAT.\u00a0 The code is checked in <a href=\"https:\/\/xcat.svn.sourceforge.net\/svnroot\/xcat\/xcat-core\/trunk\/xCAT-server\/share\/xcat\/install\/esx\/base.esxi4.1.tmpl\" target=\"_blank\">here<\/a>. We&#8217;ve had the ability to do stateless ESXi 4.1 since it came out and we&#8217;ve been doing stateless ESXi 4.0 as well.\u00a0 But for some of our customers, we have needed a way to get the ESXi 4.1 server on the disk.\u00a0 This seems to be the most common way people want to install VMware ESX(i) these days.\u00a0 We hope in the future more people will go stateless.\u00a0 But for now, here is our xCAT ESXi 4.1 base kickstart file:<br \/>\n[cc lang=&#8221;bash&#8221;]<br \/>\n# Sample scripted installation file<br \/>\n# edited and updated by vallard@sumavi.com<\/p>\n<p># Accept the VMware End User License Agreement<br \/>\nvmaccepteula<\/p>\n<p># Set the root password for the DCUI and Tech Support Mode<br \/>\nrootpw &#8211;iscrypted #CRYPT:passwd:key=vmware,username=root:password#<\/p>\n<p># clear all partitions.<br \/>\nclearpart &#8211;alldrives &#8211;overwritevmfs<br \/>\n# Choose the first disk (in channel\/target\/lun order) to install onto<br \/>\nautopart &#8211;firstdisk &#8211;overwritevmfs<\/p>\n<p># The install media is on the network.<br \/>\ninstall url http:\/\/#TABLE:noderes:$NODE:nfsserver#\/install\/#TABLE:nodetype:$NODE:os#\/#TABLE:nodetype:$NODE:arch#<\/p>\n<p># Set the network to DHCP on the first network adapter<br \/>\n#network &#8211;bootproto=dhcp &#8211;device=vmnic0<br \/>\nnetwork &#8211;bootproto=dhcp <\/p>\n<p># reboot automatically when we&#8217;re done.<br \/>\nreboot<\/p>\n<p># A sample post-install script<br \/>\n%post &#8211;interpreter=busybox &#8211;unsupported &#8211;ignorefailure=true<\/p>\n<p># tell xCAT management server we are done installing<br \/>\n# have to put in the IP address instead of the hostname because VMware<br \/>\n# ESXi 4.1 can not resolve IP addresses&#8230;<br \/>\necho &#8220;<xcatrequest>\\n<command>nextdestiny<\/command>\\n<\/xcatrequest>&#8221; | \/bin\/openssl s_client -quiet -connect #COMMAND: host #TABLE:noderes:$NODE:xcatmaster# | head -1 |  sed &#8216;s\/.*address\/\/g&#8217; #:3001 2>&#038;1 | tee \/tmp\/foo.log<\/p>\n<p># enable SSH on next boot:<br \/>\n%firstboot &#8211;interpreter=busybox &#8211;unsupported &#8211;level=47<br \/>\nsed -ie &#8216;s\/#ssh\/ssh\/&#8217; \/etc\/inetd.conf #ssh is too nice not to have<br \/>\n[\/cc]<br \/>\nSince this is an xCAT kickstart template then you see the #TABLE &#8230; # and #COMMAND ..# tags in there.\u00a0 Basically these are just cues for xCAT to look up the different attributes for the nodes so that it can customize this one template to be used on the entire data center.\u00a0 So the password, main HTTP server, and xCAT server are all stored in the xCAT database.<\/p>\n<p>I have two scripts in here.\u00a0 The first is the %post.\u00a0 This script simply signals back to xCAT that it is done installing so that the next time it reboots, instead of reinstalling, xCAT will tell the node to boot to hard disk. This happens right after the install.<\/p>\n<p>The second is the %firstboot script.\u00a0 Notice that I added the &#8211;level 47 to the script.\u00a0 This is important as it tells this script when to run.\u00a0 If you look at \/etc\/vmware\/init.d\/init you&#8217;ll see the levels.\u00a0 Level 48 starts the networking.\u00a0 Before the networking starts, I want to enable SSH, so I just uncomment the section inside \/etc\/inetd.conf to allow SSH to happen on boot.\u00a0 (Another thing you could do is just do an \/etc\/init.d\/TSM-SSH start)<\/p>\n<p>So this template is stored in xCAT in \/opt\/xcat\/share\/xcat\/install\/esx\/.\u00a0 You can have a node boot to it (provided the rest of xCAT is setup and copycds have been run) by doing the following:<\/p>\n<pre>nodeset &lt;noderange&gt; install=esxi4.1-x86_64-base\r\nrpower &lt;noderange&gt; boot\r\n<\/pre>\n<p>or just:<\/p>\n<pre>rinstall &lt;noderange&gt;\r\n<\/pre>\n<p>Then the template is copied into the \/install\/autoinst\/ directory and the name is changed to match the node and all variables are substituted in.\u00a0 Then the PXE server and DHCP server are set to point to the file to grab and install the node.\u00a0 This is in xCAT 2.5 which you can get now as<a href=\"http:\/\/xcat.sourceforge.net\/#download\" target=\"_blank\"> the development release<\/a> (make sure you grab the files at the bottom in the &#8216;Development Builds&#8217; section)<\/p>\n<p>Another thing that is fun to do with the ESXi kickstart file is to make a new VM as part of the kickstart install.\u00a0 Generally I recommend using an NFS server to store your VMs on, but there are cases where you just want them on the local drive.\u00a0 As part of the above kickstart file, the datastore1 partition is created.\u00a0 This is a place where you could now run the vim-cmds during post to create machines.\u00a0 This is easy to do during the firstboot section (you would probably do this at level 99) but not so easy to do in the %post section.<\/p>\n<p>The problem with the %post section is that hostd isn&#8217;t running so none of the vim-cmds will work.\u00a0 So you have to start it.\u00a0\u00a0 This can be done by running:<\/p>\n<pre>\/etc\/init.d\/hostd start\r\n<\/pre>\n<p>But wait, there is another problem!\u00a0 The hostd command doesn&#8217;t return and hangs!\u00a0 So you have to use some magic (like creating a script to run it that forks off and returns) otherwise your %post hangs forever. (This is a total bug)<\/p>\n<p>Anyway once you work around that then just running the commands like:<\/p>\n<pre>\/bin\/vim-cmd solo\/registervm \/vmfs\/volumes\/datastore1\/vm01\/vm01.vmx vm01\r\n\/bin\/vim-cmd vmsvc\/power.on 16\r\n<\/pre>\n<p>Seems to work.\u00a0 But, during %firstboot, you&#8217;ll have to reregister them again.<\/p>\n<p>I hope to put more information on this as we go forward with it.\u00a0 I am happy that VMware has made this kickstart file for 4.1 and I can only see it improving over time.\u00a0 The more automation the better and with kickstart we can really automate everything we need.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently added the ESXi 4.1 base template kickstart file to xCAT.\u00a0 The code is checked in here. We&#8217;ve had the ability to do stateless ESXi 4.1 since it came out and we&#8217;ve been doing stateless ESXi 4.0 as well.\u00a0 But for some of our customers, we have needed a way to get the ESXi&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/181"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":6,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":2815,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions\/2815"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}