A wrapper around the Puppet Host Resource for managing operating system host entries via Hiera.
- Puppet version 3 or greater with Hiera support
- Puppet Modules:
OS Family | Module |
---|---|
ALL | clabs/core |
Load the host class via Puppet code or ENC:
include hosts
All configuration settings should be defined using Hiera.
A standard/minimal hosts configuration is always present for convenience.
The follow shows the minimal standard in YAML format:
hosts::add:
'localhost':
'ensure' : 'present'
'ip' : '127.0.0.1'
'host_aliases' :
- 'localhost.localdomain'
'comment' : '## IPv4 loopback'
'localhost6':
'ensure' : 'present'
'ip' :
'host_aliases' :
- 'ip6-localhost'
- 'ip6-loopback'
- 'localhost6.localdomain6'
'comment' : '## IPv6 loopback & friends'
'ip6-localnet':
'ensure' : 'present'
'ip' : 'fe00::0'
'ip6-mcastprefix':
'ensure' : 'present'
'ip' : 'ff00::0'
'ip6-allnodes':
'ensure' : 'present'
'ip' : 'ff02::1'
'ip6-allrouters':
'ensure' : 'present'
'ip' : 'ff02::2'
'ip6-allhosts':
'ensure' : 'present'
'ip' : 'ff02::3'
%{::fqdn}:
'ensure' : 'present'
'ip' : %{::ipaddress}
'host_aliases' :
- %{::hostname}
'comment' : '## Other hosts, starting with myself'
You may alter the the standard host entries as needed.
In the following example with Hiera Deeper Merging enabled:
- disable the localhost6 entry
- add an additional alias to a host while inheriting/preserving the remaining standard entries
Hiera config: hosts/myhostname.yaml
hosts::add:
'localhost6':
'ensure' : 'absent'
%{::hostname}:
'host_aliases':
- 'myalias.foo.com'
In the following example:
- add an additional host entry
- preserve/inherit the remaining standard entries
hosts::add:
'mynewhost':
'ip' : '1.2.3.4'
'host_aliases' :
- 'mynewhost.mydomain.com'