Note: this is an xCAT design document, not an xCAT user document. If you are an xCAT user, you are welcome to glean information from this design, but be aware that it may not have complete or up to date procedures.
xCAT has supported the running of postscripts and postbootscripts for deployment of Linux node. This design is focus on how to support the running of postscripts and postbootscripts during deployment of Windows compute nodes.
The basic functionalities:
:Support to run postscripts before the first reboot.
:Support to run postbootscripts after the first reboot.
:Support to pass arguments to postscripts and postbootscripts. The usage of how to pass arguments to postscripts and postbootscripts is same with Linux. e.g., postscripts="script1 p1 p2,script2,..."
:Support to export environment variables for postscript and postbootscript to use in runtime. Windows node will share the same template with Linux node at: /opt/xcat/share/xcat/templates/mypostscript/mypostscript.tmpl
:The default postscripts/postbootscripts which are set in the 'postscripts.xcatdefaults' will be ignored by Windows compute node.
:The running order of postscripts is same with Linux that the postscripts which are set in osimage will be run first and then the ones in node definition.
:*No Service node and updatenode are considered.
The mypostscript.tmpl is a template which is used to create the mypostscript script which includes environment variables and postscripts to run in compute node. The default path of it is /opt/xcat/share/xcat/templates/mypostscript/mypostscript.tmpl. If you want to customize it, copy it to /install/postscripts/mypostscript.tmpl and customize it with the rules in [Postscripts_and_Prescripts].
The scripts can be any file which can be run in Windows OS.
Since Windows OS recognizes the file type by the postfix, all the postscripts which are created for Windows compute node should have correct postfix like .bat, .cmd, .vbs, .ps1
When running of postscripts, the running log will be written to c:\xcatpost\xcat.log. Admin can check the log at anytime for checking and debugging.
On the xCAT management node, copy the postscripts/postbootscripts to /install/winpostscripts. If there are files which will be called by your scripts, also copy them to /install/winpostscripts
cp <scripts> /install/winpostscripts</scripts>
Note: the scripts which are set by postscripts.xcatdefaults will be ignored.
chdef <node> postscript="xx arg1 arg2,yy" postbootscripts="aa,bb arg1"
chdef -t osoimage <osimage name=""> postscript=xx,yy postbootscripts=aa,bb</osimage></node>
In the first pass support, the '''precreatemypostscripts''' must be enabled. That means for any changes in postscript/postscripts attributes or mypostscript.tmpl, the nodeset command must be run to refresh the mypostscript.
chdef -t site clustersite precreatemypostscripts=1
In existed code logic, there is a install/autoinst/<node>.cmd file which is used to initiate the OS deployment. Following piece of code will be added in <node>.cmd to copy the files.
If existed mypostscript.<node> in MN:/install/mypostscript
copy MN:/install/mypostscript/mypostscript.<node> c:\xcatpost\
oppy MN:/install/winpostscripts/* c:\xcatpost\
Else
Do nothing
End if</node></node></node></node>
Create a script named 'xcatwinpost.vbs' which will be used to initiate the postscript mechanism. Create a script named 'runpost.vbs' which will be used to run postscript and log debug messages.
Both of the scripts will be installed at /install/winpostscripts/ on xCAT MN and SN by xCAT rpm. Them will be copied to compute node by section: '''Copy postscripts needed stuffs to compute node'''
xcatwinpost.vbs will parse the mypostscript.<node> and generate the mypostscript.cmd for postscripts running and mypostbootscript.cmd for postbootscripts running.</node>
===Inject xcatwinpost.vbs===
Inject the xcatwinpost.vbs in unattend.xml so that it can be called during node deployment by Windows setup program
Add a section like following in /install/autoinst/<node>.xml when run nodeset command:
<runsynchronous>
<runsynchronouscommand wcm:action="add">
<description>StartPointOfPostscripts</description>
<order>50</order>
<path>c:\xcatpost\winpostscripts\xcatwinpost.vbs</path>
<willreboot>OnRequest</willreboot>
</runsynchronouscommand>
</runsynchronous></node>
Use /install/autoinst/<node>.cmd to create a file named C:\Windows\Setup\Scripts\SetupComplete.cmd on Windows compute node. This is a Windows specific file which is called automatically at the first boot. </node>
Add the file 'mypostbootscript.cmd' which is created by 'xcatwinpost.vbs' into the C:\Windows\Setup\Scripts\SetupComplete.cmd to initiate the running of postbootscripts.
Wiki: Postscripts_and_Prescripts
Wiki: XCAT_2_Mini_Designs_for_New_Features