Puppet Class: psick::hosts::dynamic
- Defined in:
- manifests/hosts/dynamic.pp
Overview
::psick::hosts::dynamic Derived from github.com/example42/puppet-hosts Manage /etc/hosts dynamically. Requires puppetdb
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'manifests/hosts/dynamic.pp', line 5
class psick::hosts::dynamic (
String $dynamic_magicvar = '', # lint:ignore:params_empty_string_assignment
Boolean $dynamic_exclude = false,
String $dynamic_ip = $facts['networking']['ip'],
Array $dynamic_alias = [$facts['networking']['hostname']],
Hash $extra_hosts = {},
Boolean $manage = $psick::manage,
Boolean $noop_manage = $psick::noop_manage,
Boolean $noop_value = $psick::noop_value,
) {
if $manage {
if $noop_manage {
noop($noop_value)
}
$magic_tag = getvar('dynamic_magicvar')
$real_tag = $dynamic_exclude ? {
true => 'Excluded',
default => "env-${magic_tag}",
}
@@host { $facts['networking']['fqdn']:
ip => $dynamic_ip,
host_aliases => $dynamic_alias,
tag => $real_tag,
}
Host <<| tag == "env-${magic_tag}" |>> {
ensure => present,
}
if $extra_hosts != {} {
$extra_hosts.each | $k,$v | {
host { $k:
* => $v,
}
}
}
}
}
|