Created
April 26, 2018 12:13
-
-
Save timogoebel/959deecff4f8ca8bcdd5fc9f95cbc8e3 to your computer and use it in GitHub Desktop.
vSphere Templates for Foreman & cloud-init with the foreman_userdata plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 -%> |
Hi timogoebel !
thks for your reply, i use foreman 1.24.2, and i try to use cloud-init client with centos8 template, i have configured : 1 userdata template for the networks config and 1 cloud-init template for custom scripts post-install, and when my new vm boot, network config is ko, no ip configured, and if i use only userdata template its works ! any ideas ?
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
These templates should be part of Foreman core starting with Foreman 1.23. These features have been incubated in a plugin. The plugin README describes the necessary steps to set this up. Note, that you don't need to have the plugin installed in Foreman 1.23 and newer.