Using cloudinit data (user_data template) with vmware

I'm running the latest foreman nightly build which has
Bug #8601: use cloudinit like user data in vsphere compute ressource - Foreman applied to it. But I can't see
anywhere in the foreman build steps where the data from the user_data
template actually gets applied to the build.
What I have done is
modified /app/models/compute_resources/foreman/model/vmware.rb

@@ -368,6 +368,7 @@ module Foreman::Model
"nic_type" => args[:interfaces].first[:type],
"network_adapter_device_key" => network_adapter_device_key
}

  •  opts["customization_spec"] = 
    

client.cloudinit_to_customspec(args[:user_data]) if args[:user_data]
client.servers.get(client.vm_clone(opts)['new_vm']['id'])
end

Is this the correct way to use the user_data template or should/does it get
used at another step of the build process when deploying from image in
vmware?

Userdata templates are passed to Fog when the VM is created, which
should then be made available via the virtualization metadata service
during VM boot. As the VM boots, the local cloud-init package will
query the metadata service (usually on link-local address
169.254.169.254) to obtain the rendered template and act on it.

My experience of VMWare is extremely limited, but to my knowledge it
doesn't have a metadata service, which is probably why it's not
working for you. Image-based VMWare is normally used with SSH finish
templates, which are executed directly by Foreman once the VM is up.

Hope that helps,
Greg

the purpose of this pr was to emulate cloudinit functionality for vmware by
transforming the rendered user_data template into a customisation spec hash
that is then passed to fog and handled then.
what is what s not working in this case?
regards,

··· El 10/04/2015 02:40, "Greg Sutcliffe" escribió:

Userdata templates are passed to Fog when the VM is created, which
should then be made available via the virtualization metadata service
during VM boot. As the VM boots, the local cloud-init package will
query the metadata service (usually on link-local address
169.254.169.254) to obtain the rendered template and act on it.

My experience of VMWare is extremely limited, but to my knowledge it
doesn’t have a metadata service, which is probably why it’s not
working for you. Image-based VMWare is normally used with SSH finish
templates, which are executed directly by Foreman once the VM is up.

Hope that helps,
Greg


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Karim

The way I'm using the user-data template is to pass the Customization Spec
data to vmware when it creates the vm from a template.
Currently, none of this data is passed to Fog (vm_clone.rb) from Foreman
when deploying a vm from template (unless I'm missing something?), unless I
add the lines into Foreman
(app/models/compute_resources/foreman/model/vmware.rb) as mentioned earlier.

I was just about to document this for 1.8, but I agree with Francois as
reading the code, I can't see where the new "cloudinit_to_customspec"
method in Fog is called.

Francois' proposed patch would explicitly call it from the compute
resource during VM creation.

https://github.com/fog/fog/commit/38dd817 appears to simply be a method
exposed in Fog, and
https://github.com/theforeman/foreman/commit/5b1f7529 only appears to
only change the UI. Setting user_data on the Image should mean that a
rendered :user_data template is passed into the compute_attributes hash,
which is passed to the VMware class's create_vm method, but beyond that
I don't see what would use it.

Cheers,

··· On 12/04/15 22:33, Francois Herbert wrote: > Hi Karim > > The way I'm using the user-data template is to pass the Customization > Spec data to vmware when it creates the vm from a template. > Currently, none of this data is passed to Fog (vm_clone.rb) from Foreman > when deploying a vm from template (unless I'm missing something?), > unless I add the lines into Foreman > (app/models/compute_resources/foreman/model/vmware.rb) as mentioned earlier.


Dominic Cleal
Red Hat Engineering

my bad then.
the original pullrequest i made had the change in computeresources but i
rebased at some point and forgot this part…

··· El 27/04/2015 15:28, "Dominic Cleal" escribió:

On 12/04/15 22:33, Francois Herbert wrote:

Hi Karim

The way I’m using the user-data template is to pass the Customization
Spec data to vmware when it creates the vm from a template.
Currently, none of this data is passed to Fog (vm_clone.rb) from Foreman
when deploying a vm from template (unless I’m missing something?),
unless I add the lines into Foreman
(app/models/compute_resources/foreman/model/vmware.rb) as mentioned
earlier.

I was just about to document this for 1.8, but I agree with Francois as
reading the code, I can’t see where the new "cloudinit_to_customspec"
method in Fog is called.

Francois’ proposed patch would explicitly call it from the compute
resource during VM creation.

https://github.com/fog/fog/commit/38dd817 appears to simply be a method
exposed in Fog, and
https://github.com/theforeman/foreman/commit/5b1f7529 only appears to
only change the UI. Setting user_data on the Image should mean that a
rendered :user_data template is passed into the compute_attributes hash,
which is passed to the VMware class’s create_vm method, but beyond that
I don’t see what would use it.

Cheers,


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

opened Bug #10305: cloudinit like user data in vsphere compute ressource: missing part - Foreman +
https://github.com/theforeman/foreman/pull/2333 to incorporate your fix.
regards,

··· On Mon, Apr 27, 2015 at 7:44 PM, Karim Boumedhel wrote:

my bad then.
the original pullrequest i made had the change in computeresources but i
rebased at some point and forgot this part…
El 27/04/2015 15:28, “Dominic Cleal” dcleal+g@redhat.com escribió:

On 12/04/15 22:33, Francois Herbert wrote:

Hi Karim

The way I’m using the user-data template is to pass the Customization
Spec data to vmware when it creates the vm from a template.
Currently, none of this data is passed to Fog (vm_clone.rb) from Foreman
when deploying a vm from template (unless I’m missing something?),
unless I add the lines into Foreman
(app/models/compute_resources/foreman/model/vmware.rb) as mentioned
earlier.

I was just about to document this for 1.8, but I agree with Francois as
reading the code, I can’t see where the new "cloudinit_to_customspec"
method in Fog is called.

Francois’ proposed patch would explicitly call it from the compute
resource during VM creation.

https://github.com/fog/fog/commit/38dd817 appears to simply be a method
exposed in Fog, and
https://github.com/theforeman/foreman/commit/5b1f7529 only appears to
only change the UI. Setting user_data on the Image should mean that a
rendered :user_data template is passed into the compute_attributes hash,
which is passed to the VMware class’s create_vm method, but beyond that
I don’t see what would use it.

Cheers,


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.