salt icon indicating copy to clipboard operation
salt copied to clipboard

Feature request: customization specification configurable for the vmware driver

Open ksmitdevops opened this issue 11 years ago • 12 comments

I've seen folks use a customization option in their vmware profile configurations around the net, but I dont see it listed in the docs. I tried using it in our configuration, but it appears to be ignored. This option is used for vmware customization specifications, which we use heavily in our environment, and so this feature would be useful.

Here is our config:

cat /etc/salt/cloud.providers.d/vmware.conf

vmware:
  driver: vmware
  user: 'user'
  password: 'password'
  url: 'vc.fqdn'

cat /etc/salt/cloud.profiles.d/vmware.conf

django_web:
  provider:      vmware
  clonefrom:     django_web_template
  deploy:        False

  num_cpus:      1
  memory:        4GB

  resourcepool:  Prod
  cluster:       DC6 Live
  datastore:     VNX_5400_Tier
  folder:        Salt-Cloud-Testing
  deploy:        False 
  password:      password
  minion:
    master:      salt-master.fqdn 
  power_on:      True
  customization: Linux

ksmitdevops avatar Oct 07 '15 20:10 ksmitdevops

@schlagify, thanks for the report.

@nmadhok

jfindlay avatar Oct 09 '15 18:10 jfindlay

@schlagify What does the customization do or rather what do you expect it to do? Currently that option doesn't exist in the VMware cloud driver but if you've got a good use case, we'll be happy to add the functionality.

nmadhok avatar Oct 09 '15 19:10 nmadhok

Hi,

I was expecting an option that let's us choose a vmware "customization specification".. which is used by vmware to handle some deployment steps following guest OS provisioning. It handles various things, like applying the hostname to the newly provisioned vm and some other things. We can choose a customization spec via the vsphere ui, but it's not possible to use with salt-cloud.

In our setup, we have a template which has salt installed already and an init script which detects that a vm is newly provisioned (this edits various files in /etc to update the new hostname of the vm and runs some salt states to bring the vm up 100%). We choose a customization spec which vmware uses to set the new vm's hostname.. after that, our init script takes it from there. We were intending to use salt-cloud to launch the provisioning process, but w/o it supporting customization specifications, our newly provisioned vm's come online with the same hostname that our template had.. which isn't useful.

ksmitdevops avatar Oct 09 '15 20:10 ksmitdevops

@schlagify Specify deploy: False and see if that helps.

Update: I misunderstood what you want. I will have to look into how a customization profile can be added/specified for the VM. Do you know how that can be done in PowerShell by any chance?

nmadhok avatar Oct 09 '15 22:10 nmadhok

@nmadhok unfortunately i do not. However, I suspect that what I need may actually be accomplished with the deploy option b/c all I really need is to have salt-cloud set the hostname of my newly provisioned vm's. Unfortunately, when I do use deploy: True, it provisions my vm and even installs salt, however it does not set the hostname of the new vm. The hostname doesn't seem to be accessible anywhere, as it's not set as a grain or anything at all that I can find. The vm keeps the old hostname of the template, iow. A customization profile would normally assign the new hostname to the vm in vmware itself, and then I would have the vm's run various salt states which set the new hostname in /etc config files. Is there a recommended way of getting salt-cloud itself to set the hostname of a new vm?

thanks again

ksmitdevops avatar Oct 12 '15 19:10 ksmitdevops

@schlagify Even with deploy: True, it would set the hostname of the VM. With deploy: False, it doesn't install or configure salt-minion and doesn't transfer/accept/generate any minion keys. It would still set the hostname of the VM. When your VM comes up, you can have a salt state that runs to change the hostname to whatever you like.

What I'm curious about is why do you want to change the hostname that is being set? What issue/problem are you facing with the hostname set by VMware cloud driver itself?

nmadhok avatar Oct 12 '15 19:10 nmadhok

@nmadhok ok, so the problem is that salt-cloud is not actually setting the hostname anywhere that i can find. what's happening is the newly provisioned vm comes online with the hostname of the template, and it just stays that way. salt-cloud handles the pki keys on the master, but it is not succeeding at setting the hostname of my new vm's, and i'm not seeing messages related to it trying to do so on the cli for salt-cloud, nor am i finding anything in /var/log/salt/minion.

according to this, https://groups.google.com/forum/#!searchin/salt-users/cloud$20hostname/salt-users/VMwlWKYg-bk/PL4NFB8N9UwJ, it seems that salt-cloud is supposed to set the hostname in the new vm's id grain, but it is not doing that fwict.

i know that i can run salt states that will handle the configuration files and stuff for the new hostname, but how do i provide them with the actual hostname of the new vm if salt-cloud isn't actually giving the new vm it's new hostname? it's not provided as a grain, nor is it placed in /etc/hostname by salt-cloud, nor anywhere else that i can find. the hostname basically remains the same hostname of my template, so the salt states won't change the hostname at all in the config files anyway. this is where i am stuck, and is why i was asking for a feature request supporting customization specs (which handle hostnames seemlessly). i just need salt-cloud to set the hostname of my new vm's and then i can take it from there using salt states to handle the rest.

ksmitdevops avatar Oct 12 '15 19:10 ksmitdevops

@schlagify You have to have VMware tools installed on your template for it to be able to set the host name to the ID/name of the VM. Can you build the VM in debug mode and paste/email the debug log output so that I can further troubleshoot? You can build VM in debug mode by appending -l debug to the command you're using at the CLI to build your VM.

nmadhok avatar Oct 12 '15 20:10 nmadhok

ok, i do have vmware tools 9.4.6.33107 installed via open-vm-tools. vmware suggests that we use the latter for debian 8 (ref: http://partnerweb.vmware.com/GOSIG/Debian_8.html), so we have that installed.. and i verified that vmtoolsd does run when the vm comes online.

the debug log from my salt-cloud command with deploy: True is here: https://gist.github.com/schlagify/fc0b3c449ea1308c2904. i cleaned up a bit of the output so that we aren't giving away passwords and whatnot, so lmk if you see something funky formatting wise.

the resulting nested.output (at the end) shows that it has set the new vm's minion id grain to be our new server name, however... after I log into this new vm, does show it does not show up in the output of salt-call grains.get id or salt-call grains.items. at this point, my new vm still has the original hostname of the template and there seems to be no way to access the value of the new hostname for the vm.

ksmitdevops avatar Oct 12 '15 21:10 ksmitdevops

I've added additional debug output when deploy: False here: https://gist.github.com/schlagify/3426597fb23a839193ab

Same issue, hostname is still the same as it was for the template.

--snip id: lnprdns01 --snip

The above is useful (which is in the resulting debug output), however salt-cloud is not really setting the id grain to lnprdns01, which is what I think I need in order to finish setting up the new vm.

ksmitdevops avatar Oct 13 '15 15:10 ksmitdevops

@schlagify id is different from hostname. What is the output when you run hostname command on your newly built server? Do you already have salt-minion installed and configured in your template? If that's the case then remove any configuration under /etc/salt/ on the template and let the bootstrap script install/configure it for you.

Also, In your map file, specify the following:

deploy: True
minion:
  id: mytestminion.domain.com

you can also set a grain:

grain:
  foo: bar
  custom_grain: custom_value

Can you also please post the profile/map file you are using. Make sure to remove any passwords from it.

nmadhok avatar Oct 13 '15 16:10 nmadhok

@nmadhok The problem seems to have been a /etc/salt/minion file that was in place on the template which wasn't being overwritten by salt-cloud. Once i removed it from my template, salt-cloud provisioned the vm, wrote a new /etc/salt/minion with the real hostname as the id and from there I can now have reactor take over. I'm closing this out now that I have what I need to proceed. Thank you for your help!

ksmitdevops avatar Oct 14 '15 13:10 ksmitdevops