Automating client builds on VMWare with foreman_bootdisk

Hi there,

I'm experimenting with Foreman 1.4.1 and spinning up some test Virtual
machines on our VMWare ESXi hosts.

Unfortunately, we don't have DHCP on our environment, so I think I'm facing
the enhancement request described by Foreman Issue 3287
<Feature #3287: Connect boot ISO when creating a new VM and boot from it - Boot disk - Foreman>whereby:

"User wants to be able to connect foreman bootiso when creating a new VM
and boot from it as an alternative to PXE boot (they using vmware as
virtualization platform.)

There are networks where PXE boot not is possible due to various reasons a
good alternative to PXE boot would be to having foreman connect an foreman
bootiso to the VM when it's created and boot from it instead."

My test workflow was to create a boot ISO with foreman_bootdisk, mount it
up on the VM and proceed to boot it. This worked fine, but I'm wondering
if there's an easy way to try and and script this a little.

Questions:

When the VM is created, it doesn't have a CD/DVD drive attached. That
means I needed to power it off, create the device, reboot and attach the
ISO. Is there a setting I need to modify to add the CD/DVD device when the
VM is created?

I've not used the CLI tools but I wonder if I could use a combination of
the hammer CLI and vSphere CLI to create the host in Foreman, generate an
ISO image, SCP it to the ESXi host and then have the host boot from it.
Does that sound like a good option or is there a better solution I'm
overlooking?

Finally, is there a way to extract from Foreman a set of hammer commands
that correspond to a host?

Thanks for your help!

Richard.

> Hi there,
>
> I'm experimenting with Foreman 1.4.1 and spinning up some test Virtual
> machines on our VMWare ESXi hosts.
>
> Unfortunately, we don't have DHCP on our environment, so I think I'm
> facing the enhancement request described by Foreman Issue 3287
> <Feature #3287: Connect boot ISO when creating a new VM and boot from it - Boot disk - Foreman>whereby:
>
> "User wants to be able to connect foreman bootiso when creating a new VM
> and boot from it as an alternative to PXE boot (they using vmware as
> virtualization platform.)
>
> There are networks where PXE boot not is possible due to various reasons
> a good alternative to PXE boot would be to having foreman connect an
> foreman bootiso to the VM when it's created and boot from it instead."
>
> My test workflow was to create a boot ISO with foreman_bootdisk, mount
> it up on the VM and proceed to boot it. This worked fine, but I'm
> wondering if there's an easy way to try and and script this a little.
>
> Questions:
>
> When the VM is created, it doesn't have a CD/DVD drive attached. That
> means I needed to power it off, create the device, reboot and attach the
> ISO. Is there a setting I need to modify to add the CD/DVD device when
> the VM is created?

No, this is another feature request:
http://projects.theforeman.org/issues/3910

I have seen people use foreman_hooks to change VMware properties, so it
might be possible via rbvmomi, as is suggested in the issue above.

> I've not used the CLI tools but I wonder if I could use a combination of
> the hammer CLI and vSphere CLI to create the host in Foreman, generate
> an ISO image, SCP it to the ESXi host and then have the host boot from
> it. Does that sound like a good option or is there a better solution
> I'm overlooking?

That seems feasible, you'd just add the host to Foreman as a fully
managed PXE boot host with the MAC address given by VMware.

> Finally, is there a way to extract from Foreman a set of hammer commands
> that correspond to a host?

Not exactly, but you could look at production.log and the list of
parameters when you add a host (i.e. the POST /hosts request) and then
can probably replicate much of that on the command line to hammer host.


is a good reference too.

··· On 07/03/14 13:03, Richard wrote:


Dominic Cleal
Red Hat Engineering

Thank you Dominic. I'll give this a go.

··· On Friday, 7 March 2014 13:16:35 UTC, Dominic Cleal wrote: > > On 07/03/14 13:03, Richard wrote: > > Hi there, > > > > I'm experimenting with Foreman 1.4.1 and spinning up some test Virtual > > machines on our VMWare ESXi hosts. > > > > Unfortunately, we don't have DHCP on our environment, so I think I'm > > facing the enhancement request described by Foreman Issue 3287 > > whereby: > > > > "User wants to be able to connect foreman bootiso when creating a new VM > > and boot from it as an alternative to PXE boot (they using vmware as > > virtualization platform.) > > > > There are networks where PXE boot not is possible due to various reasons > > a good alternative to PXE boot would be to having foreman connect an > > foreman bootiso to the VM when it's created and boot from it instead." > > > > My test workflow was to create a boot ISO with foreman_bootdisk, mount > > it up on the VM and proceed to boot it. This worked fine, but I'm > > wondering if there's an easy way to try and and script this a little. > > > > Questions: > > > > When the VM is created, it doesn't have a CD/DVD drive attached. That > > means I needed to power it off, create the device, reboot and attach the > > ISO. Is there a setting I need to modify to add the CD/DVD device when > > the VM is created? > > No, this is another feature request: > http://projects.theforeman.org/issues/3910 > > I have seen people use foreman_hooks to change VMware properties, so it > might be possible via rbvmomi, as is suggested in the issue above. > > > I've not used the CLI tools but I wonder if I could use a combination of > > the hammer CLI and vSphere CLI to create the host in Foreman, generate > > an ISO image, SCP it to the ESXi host and then have the host boot from > > it. Does that sound like a good option or is there a better solution > > I'm overlooking? > > That seems feasible, you'd just add the host to Foreman as a fully > managed PXE boot host with the MAC address given by VMware. > > > Finally, is there a way to extract from Foreman a set of hammer commands > > that correspond to a host? > > Not exactly, but you could look at production.log and the list of > parameters when you add a host (i.e. the POST /hosts request) and then > can probably replicate much of that on the command line to hammer host. > > > https://github.com/theforeman/hammer-cli-foreman/blob/master/doc/host_create.md > is a good reference too. > > -- > Dominic Cleal > Red Hat Engineering >