Puppet Class: coretx::hosts
- Defined in:
- manifests/hosts.pp
Overview
Class: coretx::hosts
Manage the hosts file (/etc/hosts) via erb template - This class will overwrite your hosts file! Based off module chrekh/puppet-hosts - origin project url: github.com/chrekh/puppet-hosts This class makes use of a custom fact (coretx/lib/facter/list_addrs.rb)
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'manifests/hosts.pp', line 7
class coretx::hosts (
Hash $hosts_file_entries = {},
String $hosts_file = '/etc/hosts',
Array $lo_names4 = [ 'localhost.localdomain', 'localhost', 'localhost4.localdomain4', 'localhost4' ],
Array $lo_names6 = [ 'localhost.localdomain', 'localhost', 'localhost6.localdomain6', 'localhost6' ],
Boolean $one_primary_ipv4 = true,
Boolean $one_primary_ipv6 = true,
Array $primary_ipv4 = split($ipv4_pri_addrs,' '),
Array $primary_ipv6 = split($ipv6_pri_addrs,' '),
Array $primary_names = [ $::fqdn, $::hostname ],
)
{
# OS file group owner defaults
case $::osfamily {
/^(FreeBSD|DragonFly|Darwin)$/: {
$root_group = 'wheel'
}
/^(AIX)$/: {
$root_group = 'system'
}
default: {
$root_group = 'root'
}
}
if empty($ipv4_pri_addrs) and empty($primary_ipv4) {
$pri_ipv4 = [ $::ipaddress ]
}
else {
$pri_ipv4 = $one_primary_ipv4 ? {
true => [ $primary_ipv4[0] ],
default => $primary_ipv4,
}
}
if empty($ipv6_pri_addrs) and empty($primary_ipv6) {
$pri_ipv6 = [ $::ipaddress6 ]
}
else {
$pri_ipv6 = $one_primary_ipv6 ? {
true => [ $primary_ipv6[0] ],
default => $primary_ipv6,
}
}
file { $hosts_file:
ensure => present,
owner => 'root',
group => $root_group,
mode => '0644',
content => template('coretx/hosts.erb'),
}
}
|