Skip to content

Instantly share code, notes, and snippets.

@timogoebel
Created April 26, 2018 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timogoebel/959deecff4f8ca8bcdd5fc9f95cbc8e3 to your computer and use it in GitHub Desktop.
Save timogoebel/959deecff4f8ca8bcdd5fc9f95cbc8e3 to your computer and use it in GitHub Desktop.
vSphere Templates for Foreman & cloud-init with the foreman_userdata plugin
#cloud-config
hostname: <%= @host.name %>
fqdn: <%= @host %>
manage_etc_hosts: true
users: {}
runcmd:
- |
<%= indent(2) { snippet('puppet_setup customized', :variables => { :full_puppet_run => true }) } %>
phone_home:
url: <%= foreman_url('built') %>
post: []
tries: 10
# This is the default puppet_setup snippet
# the only line that needs to be changed is
# the actual call to puppet.
# The parameter "--tags no_such_tag" must not be passed
# as you want puppet to do a full puppet run.
# This can be done via a parameter "full_puppet_run"
# as you can see in the example below.
<%= bin_path %>/puppet agent --config <%= etc_path %>/puppet.conf --onetime <%= @host.param_true?('run-puppet-in-installer') || @full_puppet_run ? '' : '--tags no_such_tag' %> <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
# Template for VMWare customization via open-vm-tools
identity:
LinuxPrep:
domain: <%= @host.domain %>
hostName: <%= @host.shortname %>
hwClockUTC: true
timeZone: <%= @host.params['time-zone'] || 'UTC' %>
globalIPSettings:
dnsSuffixList: [<%= @host.domain %>]
<%- @host.interfaces.each do |interface| -%>
<%- next unless interface.subnet -%>
dnsServerList: [<%= interface.subnet.dns_primary %>, <%= interface.subnet.dns_secondary %>]
<%- end -%>
nicSettingMap:
<%- @host.interfaces.each do |interface| -%>
<%- next unless interface.subnet -%>
- 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 -%>
@timogoebel
Copy link
Author

How do the rendered templates look like? As a side note: For support, it‘s best to use community.theforeman.org. Do you mind posting your question there? Feel free to ping me, i‘ll answer there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment