Provisioning from a vmware template - finish script

I am setting up provisioning from a vmware template. I cannot setup dhcp
in the environment for ssh provisioning so I'm working with the user data
template option. I've got it working to the point of provisioning the vm
and configuring the network and such as needed, but how can a finish
template be applied in addition to the user data template so the
registration, salt and freeipa bits can be completed?

thanks

-andy

User-data and SSH finish scripts are mutually exclusive, as they represent
fundamentally different ways to "complete" a machine. You'll want to add
whatever steps you need to your user-data template, perhaps starting from
something something like
https://github.com/theforeman/community-templates/blob/develop/kickstart/userdata.erb
?

··· On 12 January 2016 at 14:48, Andy Thompson wrote:

I am setting up provisioning from a vmware template. I cannot setup dhcp
in the environment for ssh provisioning so I’m working with the user data
template option. I’ve got it working to the point of provisioning the vm
and configuring the network and such as needed, but how can a finish
template be applied in addition to the user data template so the
registration, salt and freeipa bits can be completed?

That was my thinking but I still can't find a way to tie this all
together. My current user-data script is this (shamelessly borrowed off
this forum :slight_smile:

<%#
kind: user_data
name: vmware user data
oses:

  • Redhat 6
  • Redhat 7
    -%>
··· On Wednesday, January 13, 2016 at 7:29:32 AM UTC-5, Greg Sutcliffe wrote: > > On 12 January 2016 at 14:48, Andy Thompson > wrote: > >> I am setting up provisioning from a vmware template. I cannot setup dhcp >> in the environment for ssh provisioning so I'm working with the user data >> template option. I've got it working to the point of provisioning the vm >> and configuring the network and such as needed, but how can a finish >> template be applied in addition to the user data template so the >> registration, salt and freeipa bits can be completed? >> > > User-data and SSH finish scripts are mutually exclusive, as they represent > fundamentally different ways to "complete" a machine. You'll want to add > whatever steps you need to your user-data template, perhaps starting from > something something like > https://github.com/theforeman/community-templates/blob/develop/kickstart/userdata.erb > ? >

https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.customization.Specification.html

encryptionKey expects an array

globalIPSettings expects a hash, REQUIRED

identity expects an hash, REQUIRED

nicSettingMap expects an array

options expects an hash

* LinuxPrep: <~Hash> - Optional, contains machine-wide settings (note

the uppercase P)

* domain: <~String> - REQUIRED, The fully qualified domain name.

* hostName: <~String> - REQUIRED, the network host name

* hwClockUTC: <~Boolean> - Optional, Specifies whether the hardware

clock is in UTC or local time

* timeZone: <~String> - Optional, Case sensistive timezone, valid

values can be found at
https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/timezone.html
identity:
LinuxPrep:
domain: <%= @host.domain %>
hostName: <%= @host.shortname%>
hwClockUTC: true
timeZone: <%= @host.params[‘time-zone’] || ‘UTC’ %>

* globalIPSettings <~Hash> - REQUIRED

* dnsServerList <~Array> - Optional, list of dns servers - Example:

[“10.0.0.2”, “10.0.0.3”]

* dnsSuffixList <~Array> - Optional, List of name resolution suffixes

* nicSettingMap: <~Array> - Optional, IP settings that are specific to

a particular virtual network adapter

* Each item in array:

* adapter: <~Hash> - REQUIRED, IP settings for the associated virtual

network adapter

* dnsDomain: <~String> - Optional, DNS domain suffix for adapter

* dnsServerList: <~Array> - Optional, list of dns server ip

addresses - Example: [“10.0.0.2”, “10.0.0.3”]

* gateway: <~Array> - Optional, list of gateways - Example:

[“10.0.0.2”, “10.0.0.3”]

* ip: <~String> - Optional, but required if static IP

* ipV6Spec: <~Hash> - Optional, IPv^ settings

* ipAddress: <~String> - Optional, but required if setting static

IP

* gateway: <~Array> - Optional, list of ipv6 gateways

* netBIOS: <~String> - Optional, NetBIOS settings, if supplied must

be one of: disableNetBIOS’,‘enableNetBIOS’,‘enableNetBIOSViaDhcp’

* primaryWINS: <~String> - Optional, IP address of primary WINS

server

* secondaryWINS: <~String> - Optional, IP address of secondary WINS

server

* subnetMask: <~String> - Optional, subnet mask for adapter

* macAddress: <~String> - Optional, MAC address of adapter being

customized. This cannot be set by the client
nicSettingMap:
<% @host.interfaces.each do |interface| %>

  • adapter:
    dnsDomain: <%= interface.domain %>
    dnsServerList: [<%= interface.subnet.dns_primary %>, <%=
    interface.subnet.dns_secondary %>]
    gateway: [<%= interface.subnet.gateway %>]
    ip: <%= interface.ip %>
    subnetMask: <%= interface.subnet.mask %>
    <% end %>

and that part works. VM is provisioned and network/host settings are
applied.

But adding just bash scripts onto this causes it to error out since it
appears to be looking for yaml. How can I combine this into the additional
bits that need to be run once the host has been provisioned?

Were you ever able to get the finish template to run after the user-data
template completes the vm template provision process? I'm running into the
same issue.

··· On Thursday, January 14, 2016 at 12:01:03 PM UTC-5, Andy Thompson wrote: > > On Wednesday, January 13, 2016 at 7:29:32 AM UTC-5, Greg Sutcliffe wrote: >> >> On 12 January 2016 at 14:48, Andy Thompson wrote: >> >>> I am setting up provisioning from a vmware template. I cannot setup >>> dhcp in the environment for ssh provisioning so I'm working with the user >>> data template option. I've got it working to the point of provisioning the >>> vm and configuring the network and such as needed, but how can a finish >>> template be applied in addition to the user data template so the >>> registration, salt and freeipa bits can be completed? >>> >> >> User-data and SSH finish scripts are mutually exclusive, as they >> represent fundamentally different ways to "complete" a machine. You'll want >> to add whatever steps you need to your user-data template, perhaps starting >> from something something like >> https://github.com/theforeman/community-templates/blob/develop/kickstart/userdata.erb >> ? >> > > That was my thinking but I still can't find a way to tie this all > together. My current user-data script is this (shamelessly borrowed off > this forum :) > > <%# > kind: user_data > name: vmware user data > oses: > - Redhat 6 > - Redhat 7 > -%> > # > https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.customization.Specification.html > # encryptionKey expects an array > # globalIPSettings expects a hash, REQUIRED > # identity expects an hash, REQUIRED > # nicSettingMap expects an array > # options expects an hash > > # * LinuxPrep: <~Hash> - Optional, contains machine-wide settings > (note the uppercase P) > # * domain: <~String> - REQUIRED, The fully qualified domain name. > # * hostName: <~String> - REQUIRED, the network host name > # * hwClockUTC: <~Boolean> - Optional, Specifies whether the > hardware clock is in UTC or local time > # * timeZone: <~String> - Optional, Case sensistive timezone, valid > values can be found at > https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/timezone.html > identity: > LinuxPrep: > domain: <%= @host.domain %> > hostName: <%= @host.shortname%> > hwClockUTC: true > timeZone: <%= @host.params['time-zone'] || 'UTC' %> > > # * globalIPSettings <~Hash> - REQUIRED > # * dnsServerList <~Array> - Optional, list of dns servers - Example: > ["10.0.0.2", "10.0.0.3"] > # * dnsSuffixList <~Array> - Optional, List of name resolution > suffixes - Example: ["dev.example.com", "example.com"] > globalIPSettings: > dnsSuffixList: [<%= @host.domain %>] > > # * nicSettingMap: <~Array> - Optional, IP settings that are specific to > a particular virtual network adapter > # * Each item in array: > # * adapter: <~Hash> - REQUIRED, IP settings for the associated > virtual network adapter > # * dnsDomain: <~String> - Optional, DNS domain suffix for adapter > # * dnsServerList: <~Array> - Optional, list of dns server ip > addresses - Example: ["10.0.0.2", "10.0.0.3"] > # * gateway: <~Array> - Optional, list of gateways - Example: > ["10.0.0.2", "10.0.0.3"] > # * ip: <~String> - Optional, but required if static IP > # * ipV6Spec: <~Hash> - Optional, IPv^ settings > # * ipAddress: <~String> - Optional, but required if setting > static IP > # * gateway: <~Array> - Optional, list of ipv6 gateways > # * netBIOS: <~String> - Optional, NetBIOS settings, if supplied > must be one of: disableNetBIOS','enableNetBIOS','enableNetBIOSViaDhcp' > # * primaryWINS: <~String> - Optional, IP address of primary WINS > server > # * secondaryWINS: <~String> - Optional, IP address of secondary > WINS server > # * subnetMask: <~String> - Optional, subnet mask for adapter > # * macAddress: <~String> - Optional, MAC address of adapter being > customized. This cannot be set by the client > nicSettingMap: > <% @host.interfaces.each do |interface| %> > - adapter: > dnsDomain: <%= interface.domain %> > dnsServerList: [<%= interface.subnet.dns_primary %>, <%= > interface.subnet.dns_secondary %>] > gateway: [<%= interface.subnet.gateway %>] > ip: <%= interface.ip %> > subnetMask: <%= interface.subnet.mask %> > <% end %> > > and that part works. VM is provisioned and network/host settings are > applied. > > But adding just bash scripts onto this causes it to error out since it > appears to be looking for yaml. How can I combine this into the additional > bits that need to be run once the host has been provisioned? >

Any update?

··· On Friday, February 24, 2017 at 10:10:18 AM UTC-6, Matt wrote: > > Were you ever able to get the finish template to run after the user-data > template completes the vm template provision process? I'm running into the > same issue. > > On Thursday, January 14, 2016 at 12:01:03 PM UTC-5, Andy Thompson wrote: >> >> On Wednesday, January 13, 2016 at 7:29:32 AM UTC-5, Greg Sutcliffe wrote: >>> >>> On 12 January 2016 at 14:48, Andy Thompson wrote: >>> >>>> I am setting up provisioning from a vmware template. I cannot setup >>>> dhcp in the environment for ssh provisioning so I'm working with the user >>>> data template option. I've got it working to the point of provisioning the >>>> vm and configuring the network and such as needed, but how can a finish >>>> template be applied in addition to the user data template so the >>>> registration, salt and freeipa bits can be completed? >>>> >>> >>> User-data and SSH finish scripts are mutually exclusive, as they >>> represent fundamentally different ways to "complete" a machine. You'll want >>> to add whatever steps you need to your user-data template, perhaps starting >>> from something something like >>> https://github.com/theforeman/community-templates/blob/develop/kickstart/userdata.erb >>> ? >>> >> >> That was my thinking but I still can't find a way to tie this all >> together. My current user-data script is this (shamelessly borrowed off >> this forum :) >> >> <%# >> kind: user_data >> name: vmware user data >> oses: >> - Redhat 6 >> - Redhat 7 >> -%> >> # >> https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.customization.Specification.html >> # encryptionKey expects an array >> # globalIPSettings expects a hash, REQUIRED >> # identity expects an hash, REQUIRED >> # nicSettingMap expects an array >> # options expects an hash >> >> # * LinuxPrep: <~Hash> - Optional, contains machine-wide settings >> (note the uppercase P) >> # * domain: <~String> - REQUIRED, The fully qualified domain name. >> # * hostName: <~String> - REQUIRED, the network host name >> # * hwClockUTC: <~Boolean> - Optional, Specifies whether the >> hardware clock is in UTC or local time >> # * timeZone: <~String> - Optional, Case sensistive timezone, valid >> values can be found at >> https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/timezone.html >> identity: >> LinuxPrep: >> domain: <%= @host.domain %> >> hostName: <%= @host.shortname%> >> hwClockUTC: true >> timeZone: <%= @host.params['time-zone'] || 'UTC' %> >> >> # * globalIPSettings <~Hash> - REQUIRED >> # * dnsServerList <~Array> - Optional, list of dns servers - Example: >> ["10.0.0.2", "10.0.0.3"] >> # * dnsSuffixList <~Array> - Optional, List of name resolution >> suffixes - Example: ["dev.example.com", "example.com"] >> globalIPSettings: >> dnsSuffixList: [<%= @host.domain %>] >> >> # * nicSettingMap: <~Array> - Optional, IP settings that are specific >> to a particular virtual network adapter >> # * Each item in array: >> # * adapter: <~Hash> - REQUIRED, IP settings for the associated >> virtual network adapter >> # * dnsDomain: <~String> - Optional, DNS domain suffix for adapter >> # * dnsServerList: <~Array> - Optional, list of dns server ip >> addresses - Example: ["10.0.0.2", "10.0.0.3"] >> # * gateway: <~Array> - Optional, list of gateways - Example: >> ["10.0.0.2", "10.0.0.3"] >> # * ip: <~String> - Optional, but required if static IP >> # * ipV6Spec: <~Hash> - Optional, IPv^ settings >> # * ipAddress: <~String> - Optional, but required if setting >> static IP >> # * gateway: <~Array> - Optional, list of ipv6 gateways >> # * netBIOS: <~String> - Optional, NetBIOS settings, if supplied >> must be one of: disableNetBIOS','enableNetBIOS','enableNetBIOSViaDhcp' >> # * primaryWINS: <~String> - Optional, IP address of primary WINS >> server >> # * secondaryWINS: <~String> - Optional, IP address of secondary >> WINS server >> # * subnetMask: <~String> - Optional, subnet mask for adapter >> # * macAddress: <~String> - Optional, MAC address of adapter being >> customized. This cannot be set by the client >> nicSettingMap: >> <% @host.interfaces.each do |interface| %> >> - adapter: >> dnsDomain: <%= interface.domain %> >> dnsServerList: [<%= interface.subnet.dns_primary %>, <%= >> interface.subnet.dns_secondary %>] >> gateway: [<%= interface.subnet.gateway %>] >> ip: <%= interface.ip %> >> subnetMask: <%= interface.subnet.mask %> >> <% end %> >> >> and that part works. VM is provisioned and network/host settings are >> applied. >> >> But adding just bash scripts onto this causes it to error out since it >> appears to be looking for yaml. How can I combine this into the additional >> bits that need to be run once the host has been provisioned? >> >

Finish script needs a valid IP address associated with a VMWare host,
this can be usually achieved when DHCP is under Foremans control and
VM will come up correctly with correct IP address.

And user-data will work as well but just partially - there is a
conversion from cloud-init to vmware XML in fog but its very
simplistic. And it ingores "call home" so hosts stays in build mode
(and build loop).

This is very unfortunate, we need to fix this. I have heard that there
are still some people using VMWare :slight_smile:

··· On Mon, Mar 20, 2017 at 6:04 PM, Griffin Hernandez wrote: > Any update? > > > On Friday, February 24, 2017 at 10:10:18 AM UTC-6, Matt wrote: >> >> Were you ever able to get the finish template to run after the user-data >> template completes the vm template provision process? I'm running into the >> same issue. >> >> On Thursday, January 14, 2016 at 12:01:03 PM UTC-5, Andy Thompson wrote: >>> >>> On Wednesday, January 13, 2016 at 7:29:32 AM UTC-5, Greg Sutcliffe wrote: >>>> >>>> On 12 January 2016 at 14:48, Andy Thompson wrote: >>>>> >>>>> I am setting up provisioning from a vmware template. I cannot setup >>>>> dhcp in the environment for ssh provisioning so I'm working with the user >>>>> data template option. I've got it working to the point of provisioning the >>>>> vm and configuring the network and such as needed, but how can a finish >>>>> template be applied in addition to the user data template so the >>>>> registration, salt and freeipa bits can be completed? >>>> >>>> >>>> User-data and SSH finish scripts are mutually exclusive, as they >>>> represent fundamentally different ways to "complete" a machine. You'll want >>>> to add whatever steps you need to your user-data template, perhaps starting >>>> from something something like >>>> https://github.com/theforeman/community-templates/blob/develop/kickstart/userdata.erb >>>> ? >>> >>> >>> That was my thinking but I still can't find a way to tie this all >>> together. My current user-data script is this (shamelessly borrowed off >>> this forum :) >>> >>> <%# >>> kind: user_data >>> name: vmware user data >>> oses: >>> - Redhat 6 >>> - Redhat 7 >>> -%> >>> # >>> https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.customization.Specification.html >>> # encryptionKey expects an array >>> # globalIPSettings expects a hash, REQUIRED >>> # identity expects an hash, REQUIRED >>> # nicSettingMap expects an array >>> # options expects an hash >>> >>> # * LinuxPrep: <~Hash> - Optional, contains machine-wide settings >>> (note the uppercase P) >>> # * domain: <~String> - REQUIRED, The fully qualified domain name. >>> # * hostName: <~String> - REQUIRED, the network host name >>> # * hwClockUTC: <~Boolean> - Optional, Specifies whether the >>> hardware clock is in UTC or local time >>> # * timeZone: <~String> - Optional, Case sensistive timezone, valid >>> values can be found at >>> https://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/timezone.html >>> identity: >>> LinuxPrep: >>> domain: <%= @host.domain %> >>> hostName: <%= @host.shortname%> >>> hwClockUTC: true >>> timeZone: <%= @host.params['time-zone'] || 'UTC' %> >>> >>> # * globalIPSettings <~Hash> - REQUIRED >>> # * dnsServerList <~Array> - Optional, list of dns servers - Example: >>> ["10.0.0.2", "10.0.0.3"] >>> # * dnsSuffixList <~Array> - Optional, List of name resolution >>> suffixes - Example: ["dev.example.com", "example.com"] >>> globalIPSettings: >>> dnsSuffixList: [<%= @host.domain %>] >>> >>> # * nicSettingMap: <~Array> - Optional, IP settings that are specific >>> to a particular virtual network adapter >>> # * Each item in array: >>> # * adapter: <~Hash> - REQUIRED, IP settings for the associated >>> virtual network adapter >>> # * dnsDomain: <~String> - Optional, DNS domain suffix for adapter >>> # * dnsServerList: <~Array> - Optional, list of dns server ip >>> addresses - Example: ["10.0.0.2", "10.0.0.3"] >>> # * gateway: <~Array> - Optional, list of gateways - Example: >>> ["10.0.0.2", "10.0.0.3"] >>> # * ip: <~String> - Optional, but required if static IP >>> # * ipV6Spec: <~Hash> - Optional, IPv^ settings >>> # * ipAddress: <~String> - Optional, but required if setting >>> static IP >>> # * gateway: <~Array> - Optional, list of ipv6 gateways >>> # * netBIOS: <~String> - Optional, NetBIOS settings, if supplied >>> must be one of: disableNetBIOS','enableNetBIOS','enableNetBIOSViaDhcp' >>> # * primaryWINS: <~String> - Optional, IP address of primary WINS >>> server >>> # * secondaryWINS: <~String> - Optional, IP address of secondary >>> WINS server >>> # * subnetMask: <~String> - Optional, subnet mask for adapter >>> # * macAddress: <~String> - Optional, MAC address of adapter being >>> customized. This cannot be set by the client >>> nicSettingMap: >>> <% @host.interfaces.each do |interface| %> >>> - adapter: >>> dnsDomain: <%= interface.domain %> >>> dnsServerList: [<%= interface.subnet.dns_primary %>, <%= >>> interface.subnet.dns_secondary %>] >>> gateway: [<%= interface.subnet.gateway %>] >>> ip: <%= interface.ip %> >>> subnetMask: <%= interface.subnet.mask %> >>> <% end %> >>> >>> and that part works. VM is provisioned and network/host settings are >>> applied. >>> >>> But adding just bash scripts onto this causes it to error out since it >>> appears to be looking for yaml. How can I combine this into the additional >>> bits that need to be run once the host has been provisioned? > > -- > 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 foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at https://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.


Later,
Lukas @lzap Zapletal