VMware Cloud Community
Desrtrider
Enthusiast
Enthusiast

OS environment options behave differently when I use power cli to automate an rhel 6 vm vs manually creating

For some reason when  I automate building an rhel6_64 vm using power cli my hostname returns with a fqdn not a short name.

This is wreaking havoc in my test environment, because I need a short name.

I am using the exact same guest os type and all other options  that I choose when I build the vm by hand and install the iso image. 

Anyone have any ideas on what could be happening here?

thanks!

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

Could you perhaps share the code with which you create the VM ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Desrtrider
Enthusiast
Enthusiast

$VM = New-VM -Name $vmname -ResourcePool $myCluster -Datastore $my_datastore -DiskGB 160 -MemoryGB 16 -GuestId rhel6_64Guest  -NumCPU 4 -DiskStorageFormat Thin

then I install an iso image, it boots and then I change the hostname by adding the correct name (not fqdn) to the /etc/sysconfig/network-scripts/ifcfg-eth0

using dhcp

/etc/hosts untouched

/etc/sysconfig/network untouched (no hostname)

in manual vm: hostname gives shortname

in auto vm: hostname gives fqdn

Thank you!!

Reply
0 Kudos
LucD
Leadership
Leadership

That New-VM cmdlet just creates a VM, it has nothing to do with the installation of the guest OS inside that VM.

What exactly do you mean with auto mode ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Desrtrider
Enthusiast
Enthusiast

hmm, what
I mean is when I use powercli to automate the creation from the iso image I get a different behavior than when I create by hand.

Are there any environment variables or settings that "rhel6_64" sets in the environment??

I believe it must have something to do with the way the hostname is getting setup... however even if I set the hostname by hand on the powercli built vm it seems to behave differently..

need to dig around some more I guess..

If  I could put the hostname in at install it would probably be ok... however don't know how to do that in an automated fashion..

Question: Do you know of a way I could give the iso a hostname when I boot from the CD? It seems invoke-vmscript is usable only with vmware tools as far as I know..

Reply
0 Kudos
LucD
Leadership
Leadership

If I understood your question correctly, then I think something is missing here.

You use the New-VM to create a VM, but it doesn't say what you do after that step ?

Do you attach a bootable ISO and then power on the VM ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos