Problem: I am creating a host in Vsphere using template from foreman. I want that new host to take a IP provided by me while provisioning instead from DHCP server
Expected outcome:IP assigned while provisioning and the IP of new VM spawned from image should be same
Foreman and Proxy versions: 1.19.1 & 1.19.0
@Chris_Roberts hope you don’t mind me pinging you here - but I think this is an area that you have some expertise in. Any thoughts to help Sanket?
@Jonathon_Turel not a problem, ill start looking at this.
@sanketshirode You say building a host in Vsphere, are you using Foreman to do the VM creation or using something like vRealize? If you are using Foreman, in the networking tab during host create, you should be able to specify an IP as an override even if you are using DHCP.
@cintrix84 Yes i’m using Foreman.
I tried hardcoding IP when provisioning under interfaces tab but the spawned VM gets different IP from DHCP.
As i am trying image based provisioning, the IP mentioned by me while provisioning and one acquired by the newly provision host is different. Due to which i’m unable to run finish template for the new host as SSH fails.
What OS are u trying to provision?
Maybe there is a simple solution.
That is not going to work, unless the DHCP is managed by Foreman. You can’t get Foreman finish script working unless the IP address provided in Foreman is actually assigned to the VM.
You make sure that the DHCP which is managing the VM is managed by Foreman, in that case you have set your Subnet IPAM to DHCP and Foreman will create the record for you. You can either accept what Foreman offers you as the next available IP address, or put your own IP. As long as it falls into the IP pool, it will work.
Note it cannot work the other way around when DHCP is not managed by Foreman, in this case it is tempting to think you need to make sure the DHCP server assigns the VM some IP address (apparently someone/something need to create reservation for the MAC address of the VM) and then you enter the IP address into Foreman. That’s a little chicken-and-egg problem, you need to enter the IP address before the VM is actually created, so you can’t see the MAC address in advance.
So AFAIK finish script will only work if DHCP server is under Foreman’s control, or you make sure somehow that IP address entered into Foreman during VM creation is correct.
Alternatively, you can use seed scripts (user data template), there are some limitations tho on how to use these in VMWare environment.
Oracle Linux 6.9
Windows Server 2012
I have achieved it using DHCP. I was trying to figure out instead of giving dhcp control to foreman is there any other way to do it.
Finish template is working fine with Linux but it wont work with windows. So, tried using user data template for windows but getting following error
globalIPSettings are required when using Customization Spec
User data works via cloud-init which must be embedded on the image/template. Also, this only works with clouds, for oVirt/RHEV/VMWare there are some limitations, check product documentation.