VMware Cloud Community
dobyrne
Contributor
Contributor

is it possible to...

is it possible to un a whole lot of command using a script rather than running them one at a time? ie after manually installing esx3 running a script that will run all of the below?

post

esxcfg-vswitch -a vSwitch1

esxcfg-vswitch -A "70 VM Network BNE" vSwitch1

esxcfg-vswitch -A "74 VM Network BNE" vSwitch1

esxcfg-vswitch -A "76 VM Network BNE" vSwitch1

esxcfg-vswitch --pg= "70 VM Network BNE" --vlan=70 vSwitch1

esxcfg-vswitch --pg= "74 VM Network BNE" --vlan=74 vSwitch1

esxcfg-vswitch --pg= "76 VM Network BNE" --vlan=76 vSwitch1

esxcfg-vswitch -L vmnic2 vSwitch1

esxcfg-vswitch -L vmnic3 vSwitch1

service mgmt-vmware restart

sleep 20

esxcfg-vswitch -A VMkernel vSwitch0

esxcfg-vswitch -L vmnic1 vSwitch0

esxcfg-vmknic -a VMotion -i 10.4.76.173 -n 255.255.255.0

esxcfg-route 10.4.76.1

esxcfg-vswitch --pg=VMkernel --vlan=76 vSwitch0

sleep 30

service mgmt-vmware restart

sleep 30

vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-active vmnic1 vSwitch0 VMkernel"

vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-standby vmnic0 vSwitch0 VMkernel"

vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-active vmnic0 vSwitch0 ‘Service Console'"

vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-standby vmnic1 vSwitch0 ‘Service Console'"

0 Kudos
3 Replies
Schorschi
Expert
Expert

You can not/should not call esxcfg commands per kickstart %post, but you can use %post section to setup a script to run after first reboot. Either you can use BASH scripting to call the commands you outlined.

dwight
Enthusiast
Enthusiast

1. Save the commands into their own script

2. End the script with either "rm $0" or mv $0 someothername" (this will cause the script to remove itself when it's done). If you do an exit from the script you will need to add the remove commands to just before any exits as well.

3. In the post section of the kickstart config copy the script into the /etc/rc3.d directory and make sure the name begins with S08" (The S at the beginning of the name tells the rc scripts to run the script with the word "start" as the first parameter. The 08 lets it know when it should run the script (scripts are run in order, so 08 runs before the firewall and network are configured).


RHCE, VCP

Blog: http://computing.dwighthubbard.info

RHCE, VCP Blog: http://computing.dwighthubbard.info
Schorschi
Expert
Expert

We went one step farther... we wrote our own service, that can be controlled from chkconfig, this is not required, but is nice to have it you want to run a debug version of your process, or do other interesting stuff with your customization beyond the initial reboot. In our case, we run our automated QA process after a separate reboot from all other configuration steps. So our service tracks the reboots and machine state (per our automation logic), so it knows when all customization is done, and QA can be done.

0 Kudos