VMWare Server 2 Autoconfiguration
26 December 2010
by Razvan Dobre
0 comments
Hello
I have to do a large deployment of VMWare Server 2 infrastructure in our cluster at school to run about 1000 vm’s for a project. With out current infrastructure we are able to run only about 700 vm’s but it’s enought.
The instalation of the VMWare Server 2 service was easy, i just had to configure the cfagent to do it for me. The instalation was done on Scientific Linux 5.5, so the modules were allready compiled. The ugly part was running vmware-config.pl all nodes.
So I started to search the web to find an elegant solution to my problem. The were sugestions on running vmware-config.pl with a response file as input but it didn’t work (vmware-config.pl < responses). A friend sugested me to try using expect scripts to automate the task. I googled a little and found some good examples on how to use expect. Expect is a tcl toolkit designed to automate wizards witch usualy requires human interaction.
After some try-catch demos I made this tcl script that reads a response file and with the help of expect the vmware configure wizard is run without human interaction. So I configured cfagent to run this script for me all nodes. You may need to adapt the response file to your needs. I had to tweek the vmware-config.pl script not to display the licence, just the yes/no question.
Info:
- http://www.tcl.tk/man/tcl/tutorial/tcltutorial.html
- http://oreilly.com/catalog/expect/chapter/ch03.html
Script:
#!/usr/bin/expect --
set response_file "/root/bin/responses.txt"
set match [list]
set responses [list]
set program "/root/bin/vmware-config.pl"
#exp_internal 1
set infile [open $response_file r]
while { [gets $infile line] >= 0 } {
set tmp [split $line "|"]
lappend match [lindex $tmp 0]
lappend responses [lindex $tmp 1]
}
close $infile
set n [llength $match]
#exec yum -y erase VMware-server.x86_64
#exec rm -rf /etc/vmware
#exec yum -y install VMware-server.x86_64
set timeout 60
spawn $program
for {set i 0} {$i < $n} {incr i} {
set item [lindex $match $i]
set resp [lindex $responses $i]
puts "$item -> $resp"
expect -regex ".*$item.*"
send "$resp\n"
sleep 1
}
expect eof
Reponse file:
Press enter to display it|Do you accept|yesDo you want networking for your virtual machines|yesConfiguring a bridged network for vmnet0|br0Which one do you want to bridge to vmnet0|eth0Do you wish to configure another bridged network|yesConfiguring a bridged network for vmnet2|br1Which one do you want to bridge to vmnet2|eth1Do you wish to configure another bridged network|noDo you want to be able to use NAT networking in your virtual machines|noDo you want to be able to use host-only networking in your virtual machines|noPlease specify a port for remote connections to use|Please specify a port for standard http connections to use|Please specify a port for secure http \(https\) connections to use|specify a different administrator|yesPlease specify the user whom you wish to be the VMware Server administrator|vmadminIn which directory do you want to keep your virtual machine files|what you want|yesXXXXX-XXXXX-XXXXX-XXXXX|SERIALIn which directory do you want to install the VMware VIX API binary files|In which directory do you want to install the VMware VIX API library files|Is this what you want|In which directory do you want to install the VMware VIX API document pages|Is this what you want|
