I am using Foreman 1.19.1 on CentOS 7 and provisioning hosts on vCenter using templates and userdata/cloud-init method. The provisioning part of the process is working as expected. I just added a Finish Template hoping to drop in some customized scripts for respected host groups so that they can be executed once the host provisioning is completed. However, it does not appear to be running at all. How exactly do I configure the finish template so that it runs once cloud-init is completed?
You need to configure the image for compute resource so that it uses “user data”. Then make sure the template is assigned to the operating system of the host. When creating a host, there’s a resolve templates link that shows you what templates will be used during provisioning. I suppose you have all of this already in place, so the problem might be that the VM get wrong url to fetch the template. This may be Foreman misconfiguration, under Administer -> Settings see Provisioning -> “Unattended URL” and General -> “Foreman URL”. Also previewing all templates could help, go to host detail, switch to Templates tab, see corresponding template row and click Review in the drop down.
Hope some of this helps