Can't deploy a vm from a vm template

Hi,

I’ve got none so far.
I’m trying to understand how this works.
According to the documentation Foreman :: Manual #5.29 I just need to create a user/finish template to configure the IP on the vm right ?
I want to set a static IP on my VM

If someone has a template to share I’ll be more than happy.

Thank you

Hi,

I’ve made some progress. Following your advice I created a Provisioning template type Finish template (I try user data too) :

# YAML file 
<%# 
kind: user_data 
name: UserData default 
oses: 
- CentOS 4 
- CentOS 5 
- CentOS 6 
- CentOS 7 
- Debian
- SLES 9 
- SLES 10 
- SLES 11 
- SLES 12 
- Ubuntu 10.04 
- Ubuntu 11.04 
- Ubuntu 11.10 
- Ubuntu 12.04 
- Ubuntu 12.10 
- Ubuntu 13.04 
- Ubuntu 13.10 
- Ubuntu 14.04 
- Ubuntu 14.10 
- Ubuntu 15.04 
-%> 
# 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 %> 

#   * options: <~Hash> Optional operations, currently only win options have any value 
#   *   changeSID: <~Boolean> - REQUIRED, The customization process should modify the machine's security identifier 
#   *   deleteAccounts: <~Boolean> - REQUIRED, If deleteAccounts is true, then all user accounts are removed from the system 
#   *   reboot: <~String> - Optional, (defaults to reboot), Action to be taken after running sysprep, must be one of: 'noreboot', 'reboot', 'shutdown' 
#options: 
#    changeSID: true 
#    deleteAccounts: false 

This fail with error :

There was an error rendering the Debian 9 template: undefined method '#params' for Host::Managed::Jail (Host::Managed)

I found this template on Internet. I don’t understand what language is expected for finish template or User data.
Thanks for you help !

@romgo

Let me try to work with this and then I can do a demo for you if that would work?

If you want to PM me your email on here, I can schedule a Bluejeans remote session for next Tuesday.

Let me know if that would help you and get this issue solved.

Hi,

thanks, Finaly I’m able to deploy the VM and get it reconfigured for the network awesome !
I would like tho share the provisioning template I found on github :

identity:
  LinuxPrep:
    domain: <%= @host.domain %>
    hostName: <%= @host.shortname %>
globalIPSettings:
  dnsServerList: [ <%= @host.primary_interface.subnet.dns_primary %>, <%= @host.primary_interface.subnet.dns_secondary %> ]
  dnsSuffixList: [<%= @host.domain %>]
nicSettingMap:
<% @host.interfaces.each do |interface| %>
  - adapter:
      ip: <%= interface.ip %>
      subnetMask: <%= interface.subnet.mask %>
      <% if interface.primary -%>gateway: [<%= interface.subnet.gateway %>]<% end %>
<% end %>

This need of course when you deploy a vm to provide all those values.

The last issue I got is that my VM in foreman UI Build state is Pending installation
I guess I’m missing something here i’ll check that

Regards,

https://access.redhat.com/blogs/1169563/posts/3640721

here you can find a good guide. You missed the configuration steps, eg via cloud-init or via ssh. Take a look of it, it’s a really good how to