Using Hiera

See Getting Started with Hiera and in particular Using Hiera with Puppet.

  1. On the master:

    root@vhost1:~# apt-get install hiera

  2. 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
    	  

  3. In /srv/puppet/common/hiera/common.yaml, put:

    ---
    ntpserver: ntp0.xennet
    ntp::server: ntp0.xennet
    	  

  4. E.g.

    file { '/tmp/hieratest':
      ensure => 'present',
      content => hiera('ntpserver'),
    }
    	  

  5. 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]Warning

Hiera uses different default paths to hiera.yaml, depending on whether it starts standalone or as a child of Puppet.