- add class to manage the /etc/hosts file - add static hosts to /etc/hosts file via hiera array/hash
31 lines
866 B
Puppet
31 lines
866 B
Puppet
# basic class to manage the /etc/hosts file from a template
|
|
#
|
|
# @param additional_hosts:
|
|
# An array of hashes with ip/hostname/aliases
|
|
# Aliases is an array in case there is a need for multiple aliases
|
|
#
|
|
# class { 'profiles::base::hosts':
|
|
# additional_hosts => [
|
|
# { 'ip' => '192.168.0.10', 'hostname' => 'server1.example.com', 'aliases' => ['server1'] },
|
|
# { 'ip' => '192.168.0.11', 'hostname' => 'server2.example.com' },
|
|
# # ... and so on
|
|
# ],
|
|
# }
|
|
#
|
|
class profiles::base::hosts (
|
|
Array[Hash] $additional_hosts = []
|
|
) {
|
|
|
|
$fqdn = $facts['networking']['fqdn']
|
|
$hostname = $facts['networking']['hostname']
|
|
|
|
# Ensure the file exists and manage its content
|
|
file { '/etc/hosts':
|
|
ensure => file,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0644',
|
|
content => template('profiles/base/hosts.erb'),
|
|
}
|
|
}
|