VMware Communities
badouglas11
Contributor
Contributor
Jump to solution

vmware - scripting the vm creation, and os installation process

Hi.

Trying to determine the exact steps to automate the entire process of creating a VM, as well as installing a linux OS (Rhel/Centos) into the VM. I need to understand the steps to do this entirely from the the CLI using scripts. I've seen a few sites that describe the base process of creating the base VM, which appears to generate the vmdk file.

I've seen nothing that demonstrates what has to occur to install the OS into the VM, from the CLI. This process needs to be auto/programmatic, so I can't use the GUI.

I imagine that the overall process will have to invoke the kickstart file/process, and to somehow boot from that, but I don't see how the pieces fit. The goal is to then have a VM Appliance with the required OS/Apps that are then run/deployed by the external users on their machines.

If this process can work, then we can talk to a consultant/vmware about the next phase of the project.

So, replies that either detail how to accomplish this, or point to articles/sites on this would be great!

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

I just tested on a Linux system and had to run the VMware-VIX-1.10.1-266898 install twice. It fail the first time without any message in the log file.

After a successful install I ran a .vmx without first editing the /usr/lib/vmware-vix/vixwrapper-config.txt file and got the error message expected about the specified version not found and then after editing it I was able to run the .vmx using vmrun nogui.

View solution in original post

Reply
0 Kudos
24 Replies
continuum
Immortal
Immortal
Jump to solution

why do you create a new post ?

we already started to discuss this ...

Your next step is to start a "easy install" with a Centos setup iso-file.

When this install has started - suspend it.

Then copy the autoinst.flp to a safe place.

mount the autoinst.flp and inspect the content




_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

hi continuum!!

you are correct. i didn't know how the forums worked, so i didn't know

if you have different people replying to different areas. if i get

this working, i'll do a post of the solution to both sides!

so my apologies.

Your next step is to start a "easy install" with a Centos setup iso-file.

ummm.. what's an easy install?? whenever i've installed the OS, it's

always been as a dvd, or netinstall, using the GUI. (i did find

references to autoinst.flp files from the vmplayer. so it appears that

vmplayer has a way to do an "easy install" process.) is this correct?

assuming that i'm on the right track, then mounting this autoinst.flp

file, and examining the contents with a text editor will reveal

items/cmds that can then be implemented in a script form?

so is a kickstart process file contained within the file? is this part

of the process?

thanks again for not screaming at the wall on this one!!!!

When this install has started - suspend it.

Then copy the autoinst.flp to a safe place.

mount the autoinst.flp and inspect the content

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

did you ever install Centos with Workstation ?

if Workstation detects the Centos-iso it offers the "easy install" feature.

This actually creates an answer file - or if I remember right in Redhat terms this is a kickstart-file.

This answer file then is written to a virtual floppy - the autoinst.flp.

After installation this autoinst.flp will be automatically deleted - so to grab it you must copy it before the install finishes.

So you would do this install once via the GUI - and then next time you can re-use this autoinst.flp to run the install completely silently - without user intervention




_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi Again!!

Never installed any os via vmware. Just from what I've done on bare

metal with other OS systems.

So the issue now is to do a easy install, using vmplayer/vm

workstation, and to somehow stop it mid way through to see if i get an

autoinst.flp file..

If I get this file, to then mount it and see if there's anything in

the file. And to then examine the contents.

I'm game, let's see where this process goes.

But assuming there's anything in the autoinst.flp file, what do I do

with the contents? Are the contents expected to be shell commands? Are

the contents something else?

Wonder if I could find a sample of the autoinst.flp file on the net??

Thanks

On Mon, Nov 8, 2010 at 12:30 PM, continuum

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

You don't actually have to stop the install process and can just grab a copy of the autoinst.flp file during the install. You can open the file with WinImage

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi Again...

Ok, I tried to install RHEL/Centos via the ISO file on the drive,

using vmware vmplayer.

vmplayer detected the iso to create a new vm, and to install the os.

tried to see if the autoinst.flp file was anywhere in the dir with the

vmware vm files (vmx/vmdk) but didn't see it.

did a suspend to see if the file would be created. it's not there. i

do have a autoinst.iso file.

any other approaches to take?

thanks

On Mon, Nov 8, 2010 at 12:30 PM, continuum

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

do not click "I will install later" - this disables "easy install"

if the iso-file you use is not detected try another one

- I just tried and saw that Centos uses a second iso-file instead of a floppy - inscpect this one I attached




_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

hi woody.

where in the process is the autoinst.flp created?

my steps::

download vmware-vmplayer

-create new vm/install OS (Rhel)

-run the create/install process

-view the dir "/apps/vmware/rhel"

never saw the autoinst.flp file at all...

did i miss something?

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

in Centos the autoinst.iso has a ks.cfg file with a content like this - you can edit that to fit your needs

lang en_US
#langsupport --default en_US
network --bootproto dhcp
cdrom
keyboard us
zerombr yes
clearpart --all --initlabel
part /boot --size 50
part swap --recommended
part / --size 3000 --grow --maxsize 4000
part /home --size 1000 --grow
install
#mouse generic3ps/2
firstboot --disable
firewall --enabled
timezone --utc America/Los_Angeles
xconfig --startxonboot --resolution=800x600
rootpw --iscrypted $1$8W1ALUmV$vBmhMQ6MDVCIWKh4pGblg0
reboot
auth --useshadow --enablemd5
bootloader --location=mbr
key --skip
%packages
python
@ X Window System
@ GNOME Desktop Environment
@ Graphical Internet
@ Development Tools

#%end
%post
cp /boot/grub/menu.lst /boot/grub/grub.conf.bak
sed -i 's/ rhgb//' /boot/grub/grub.conf
cp /etc/rc.d/rc.local /etc/rc.local.backup
cat >>/etc/rc.d/rc.local <<EOF
echo
echo "Installing VMware Tools, please wait..."
if [ -x /usr/sbin/getenforce ]; then oldenforce=\$(/usr/sbin/getenforce); /usr/sbin/setenforce permissive || true; fi
mkdir -p /tmp/vmware-toolsmnt0
for i in hda sr0 scd0; do mount -t iso9660 /dev/\$i /tmp/vmware-toolsmnt0 && break; done
cp -a /tmp/vmware-toolsmnt0 /opt/vmware-tools-installer
chmod 755 /opt/vmware-tools-installer
cd /opt/vmware-tools-installer
mv upgra32 vmware-tools-upgrader-32
mv upgra64 vmware-tools-upgrader-64
mv upgrade.sh run_upgrader.sh
chmod +x /opt/vmware-tools-installer/*upgr*
umount /tmp/vmware-toolsmnt0
rmdir /tmp/vmware-toolsmnt0
if [ -x /usr/bin/rhgb-client ]; then /usr/bin/rhgb-client --quit; fi
cd /opt/vmware-tools-installer
./run_upgrader.sh
mv /etc/rc.local.backup /etc/rc.d/rc.local
rm -rf /opt/vmware-tools-installer
sed -i 's/3:initdefault/5:initdefault/' /etc/inittab
mv /boot/grub/grub.conf.bak /boot/grub/grub.conf
if [ -x /usr/sbin/getenforce ]; then /usr/sbin/setenforce \$oldenforce || true; fi
telinit 5
EOF
/usr/sbin/adduser dude
/usr/sbin/usermod -p '$1$8W1ALUmV$vBmhMQ6MDVCIWKh4pGblg0' dude
/usr/bin/chfn -f "example dude" dude
#%end






_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi.

do not click "I will install later" - this disables "easy install"

i didn't... vmplayer showed me easy install.

when i selected the RHEL Iso, it started to install....

i just never saw the autoinst.flp file

if the iso-file you use is not detected try another one

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi.

are you saying to let the entire install process go through with both

ISO files, instead of stopping the process, and that the autoinst.flp

should be created then?

On Mon, Nov 8, 2010 at 1:32 PM, continuum

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi Continuum,

So this is the kickstart file.

But I still have no idea of what to do with the kickstart, and the vmdk.

Basically, how do I hook the kickstart into the VM..

This is the critical issue(s) that I'm missing. This is where

(unfortunately) i need the exact steps.

-step 1`) do this..

-step 2`) do that..

-step 3`) do this other thing..

thanks

i think i'm getting closer..

On Mon, Nov 8, 2010 at 1:36 PM, continuum

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

inspect the attached vmx-file

the autoinst.iso is connected as ide0:0 so the VM will boot from that one

the original iso is attached as ide1:0 - not used for booting




_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

Hi Continuum,

Think I'm getting closer...

The vmx file points to the iso, which in turn has the kickstart file.

so if i run the

vmplayer aa.vmx

the app goes ahead and does the OS install with the aa.iso.

makes sense.

however, when i run the test, i'm getting the gui from the

iso/kickstart/vmplayer, so how can i "turn off"/disable the graphical

output.

thanks

On Mon, Nov 8, 2010 at 1:57 PM, continuum

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

however, when i run the test, i'm getting the gui from the iso/kickstart/vmplayer, so how can i "turn off"/disable the graphical output.

Use vmrun with the nogiu parameter to start the VM.

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

hi woody etal

my question had to do with when i run the vmplayer, that creates the

VM/installs the OS.

During the create/install process, the vmplayer/kickstart process

displays user input gui/dialogs that require the user input. I need to

figureout a way of running the entire process without requiring any

user input.

also, i have the vmplayer app, but not the vmrun app...

thanks

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

I normally do not use Easy Install however IIRC after inputting the information for the Easy Install process and then starting the install there was no addition user interaction necessary the install process went through to completion. So assuming you first do a normal install with Easy Install in order to get the necessary support files to replicate the process through automation I don't see what the issue is. You know sometimes you just have to observe the process and then reverse engineer it so to speak. Also there is a parameter you can add to the .vmx configuration file that will suppress GUI Prompts and auto answer with the best choice in some cases. Sorry don't remember it off the top of my head at the moment however its been mentions many times before in these forums.

As far as vmrun is concerned it comes as a part of VMware Workstation and for VMware Player you can download it from the page you downloaded VMware Player from. It's called VMwareVIX and have a look at: <a href="https://communities.vmware.com/support/developer/vix-api/vix110_vmrun_command.pdf" class="openpdf" target="_blank">Using vmrun to Control Virtual Machines</a>

Just curious have you tried using Google to find out some of this information or have you look at the Documentation section on VMware Player and VMware Workstation? Did you even type vmrun in Google?

I'm not trying to be a hard ass however you need to do more research as all of this has already been covered before and I'm sure it out there on the Internet.

Reply
0 Kudos
badouglas11
Contributor
Contributor
Jump to solution

hey woody...

you're not being a hardass... and i've looked high/low on the net for

this data prior to coming here. also called vmware to talk to presales

which didn't help, so yeah, i think i';ve done the homework.

now, you're free to say that maybe someone without a certain skill

level in this area should be dealing with this, and that's your right.

but the basic data that i've been searching for wasn't apparent to me.

might be quite apparent to you, but you have a different

background/understanding than i in this area.

now, having said that, i think the basic issue that I'm now facing is

how (if it's possible) to start creating a VM from a script, pointing

to the OS.

If it's not possible, then I'll create a process that goes like this:

1) create the initial "seed" VM using the GUI, specifying an OS (Rhel/Centos)

2) use the autoinst.iso, as well as the vmx to create all the future

VMs with the

specific OS

2a) I can mount/modify the files in the autoinst.iso based on the current OS,

and then recreate (mkisofs) a new copy of the autoinst.iso for the

creation of the new VM

3) once I create the new base VM, the process can then insert the

required files

into the VM, via ssh/scp (scripts) etc..

4) the results of this process should be a valid/scripted VM that

then runs on the

client env

I can then repeat steps 2-4 in a script/program/cli approach for

every additional VM

Thoughts/comments welcome.

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

I notice you didn't explicitly answer the questions I asked however that's okay.

I've not seen a single document that encompasses complete step by step directions from start to finish for what you're trying to do nonetheless the information is out there and just has to be pulled together based on the tools being used and ability of the one doing the work. Smiley Wink

Okay, as a Proof of Concept exercise I scripted the process of creating the virtual hard drive, the .vmx configuration file, and then starting the install process without the GUI and brought the VM to a shutdown upon completion of the OS and VMware Tools install. I did not create the autoinst.iso file via scripting although it certainly is possible and I have and do create other bootable iso images via scripts however I just didn't have time to script that portion for this particular case although I did customize the kickstatrt configuration file in order to have the VM shutdown after the install and used the default autoinst.iso with my customized KS.CFG file as a seed to get this done. Then after the install when starting the VM normally for the first time I did not have to deal with the normal message the would come up because of what I'd call a shortcoming in the Easy Install process however that could be fixed with additional scripting so as not to use the 'msg.autoAnswer = "TRUE"' parameter although that's not a bad parameter to have in the .vmx file and it just depends on ones needs/preferences/wants.

JSYK I did this on a Mac using a simple Bash Script and VMware Fusion however it absolutely can also be done using VMware Player under Windows as an example however with VMware Player you'll have to get vmware-vdiskmanager from VMware Workstation if you plan to create the virtual hard disk by command line. You'll also need vmrun which is available in the VIX package you can download from where you downloaded VMware Player or I guess you can grab that from Workstation too.

So here is an outline of one way and what you'll need...

If you're fine with a default CentOS Easy Install then just use the autoinst.iso from a VM created by the VMware Product GUI as part of what will be needed to script the entire process or you can create a custom Kickstart Configuration file and use the customized elements with the one created by a default CentOS Easy Install however you'll need to delete the original KS.CFG file in the autoinst.iso replacing it with your customized KS.CFG file.

I added additional Packages to my KS.CFG file because I'm going to keep the VM from this exercise however the line to modify in the original to have the VM shutdown after the install of the OS and VMware Tools is simply changing 'telinit 5' to 'telinit 0'. At a minimum this should be done if being done without a GUI and is more conducive to additional scripting to test for the completion of the install if developing a more complex scrip than the simple bash scrip I used here.

To add additional Packages I use Kickstart Configurator from another Linux VM to create a customized configuration and then just took the %packages section and blended it with the original from the autoinst.iso file.

Note: A customized autoinst.iso can be created via scripting using mkisofs in conjunction with the files from the original autoinst.iso and a customized KS.CFG file created via scripting and all done on the fly however this is more complicated then just modifying the original with a customized KS.CFG file and using it as the seed and I just don't have time to do that now for this exercise.

For the virtual hard disk again you can use the one create by a CentOS Easy Install as the seed or you can get vmware-vdiskmanager from VMware Workstation so you can create the virtual hard disk in the script.

With the support files in place it just a matter of writing the scrip and I've attached the one I created for this exercise so you can see what took place. Obviously the way this is written once executed and because no GUI is in play you have to check by other means that the actual install is finished and the VM is shutdown (the vmware-vmx process) however this is just additional coding to monitor the process and notify when complete and while I didn't do this in this script nonetheless it's doable and again I don't have the time to add it as this was mainly being done simply for Proof of Concept so you'd know it can be done.

File Attached: createvm.zip

Reply
0 Kudos