Hey,
There is another workaround when using a dhcp server
There are two options:
1) Use dhcp for all your environment (do not introduce any static 
configuration on the guest)
2) Use dhcp only for the provisioning part (the ssh finish script will 
configure the static network configuration)

I have a deployment with multiple VLANs so even here there are a few ways 
to tackle this:
For the dhcpd configuration:
1) Run multiple dhcp + smart proxy instances (per VLAN)
2) Configure a dhcp relay on each VLAN (on the switch) and relay to one 
single dhcp + smart proxy instance
3) Run one dhcp + smart proxy and configure the NIC as a trunk (on all 
those VLANs), you will have to create a VLAN interface per subnet (you can 
automate all of this with puppet + theforeman)
    If you are running this dhcp server in a VMware (or any other Cloud 
environment) you can create a distributed port group that is actually a 
trunk VLAN and then attach it to the VM running the dhcp.

Because some VMs in this deployment i am working on requires a very basic 
image (really really clean image) i have to use this approach, I make sure 
before i pack the image (I also automate the creation of those images 
through foreman) that the first interface (primary, managed, provisioning 
interface) on this VM (usually eth0) is configured to boot from dhcp and i 
make sure to remove the mac address part in the guest configuration.
For RHEL based OS you can do something like this in the post installation 
script when creating the image, before packing it:
$ rm -f /etc/udev/rules.d/70* || true
$ sed -i'' '/^\(HWADDR\)/d' /etc/sysconfig/network-scripts/ifcfg-eth* || 
true
And make sure the configuration in the ifcfg-eth<N> is set to boot from 
DHCP. (if your kickstart file networking is dhcp then it will be 
automatically configured for you)

Create appropriate Subnets (per VLAN as example) in foreman and make them 
static or dhcp (your choice, it will work both way starting from foreman 
1.11.3 http://projects.theforeman.org/issues/14905)

When you create a new host and attach the interface (make sure it's managed 
+ provisioning interface) to a Subnet, doesn't matter if the subnet is 
configured to dhcp or static, Foreman will create an entry on the DHCP 
server.
When the new VM (from the Image/Template created earlier) will boot, it 
will receive an IP address from the DHCP server, Foreman will be aware of 
that address and run the SSH finish script on the new VM.
The default SSH Finish script is aware of different networking 
configuration (fixed also in 1.11.3 but you can backport it pretty easily) 
and as part of this script it will configure the ifcfg-eth<N> accordingly 
(removing it from DHCP to STATIC as example, it can also set the HW address 
back).

It's seems complicated, but it's pretty simple :)

On Monday, October 26, 2015 at 5:39:23 PM UTC+2, Sher Chowdhury wrote:
>
> Hi,
>
>
>
> I have a "vmware template" available I've been trying to follow this guide:
>
> http://theforeman.org/manuals/1.9/index.html#5.2.9VMwareNotes 
>
> Originally I tried taking the ssh approach which involves making using of 
> a finish template. I couldn't get this to work because foreman (v1.9) 
> appears to just does a "clone" of the vmware template rather than "Deploy 
> virtual machine from this Template...". Therefore when the new VM is 
> created on vsphere (v5.5), it doesn't have any networking, and therefore 
> the ssh part times out.   
>
> I then tried, "Image provisioning without SSH". However after a few trial 
> and errors I've discovered that I can't do this without a YAML user data 
> template for the VMware customisation. At the moment the closest thing we 
> have appears to only work for cloudinit:
>
> https://github.com/theforeman/community-templates/tree/develop/cloudinit 
>
> I've also had a look at this:
>
> http://www.herbert.org.nz/?p=245
>
> But this appears to deal with provisioning windows machine, whereas I'm 
> interested in provisioning a RHEL machine. 
>
> If anyone can create a community version then I'm happy to test it out. 
>
> Has anyone else had any success in provisioning a vm from a vmware 
> template?
>
>
> Thanks,
> Sher Chowdhury
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to