See Getting Started with Hiera and in particular Using Hiera with Puppet.
Install Hiera
On the master:
root@vhost1:~# apt-get install hiera
Configure Hiera
Still on the master, edit
/etc/puppet.hiera.yaml
:
--- :backends: - yaml :logger: console :yaml: :datadir: /srv/puppet/common/hiera :hierarchy: - "%{environment}/%{calling_class}" - "%{environment}/defaults" - common
Add some data
In /srv/puppet/common/hiera/common.yaml
, put:
--- ntpserver: ntp0.xennet ntp::server: ntp0.xennet
Use Hiera in a class
E.g.
file { '/tmp/hieratest': ensure => 'present', content => hiera('ntpserver'), }
Test
On the client:
root@vhost2:~# puppet agent -t
root@vhost2:~# cat /tmp/hieratest
ntp0.xennet
To test a yaml file locally:
root@vhost1:~# hiera -c /etc/puppet/hiera.yaml ntpserver
ntp0.xennet
Warning | |
---|---|
Hiera uses different default paths to hiera.yaml, depending on whether it starts standalone or as a child of Puppet. |