Official doc here
I don't like hiera, but it's better than hardcoding configuration in .pp files.
First attempt:
vi hieratest.pp
I run "puppet apply hieratest.pp" and I get:
Hiera config file /etc/puppetlabs/puppet/hiera.yaml not readable at /root/puppettests/hieratest.pp:1
then I do vi /etc/puppetlabs/puppet/hiera.yaml and I enter:
and rerun "puppet apply hieratest.pp" and I get:
so I do "mkdir /etc/puppetlabs/puppet/hieradata/" and vi /etc/puppetlabs/puppet/hieradata/common.yaml (remark: common is a member of the hierarchy in the hiera.yaml' and I enter
pippo : 'hello world!'
Again "puppet apply hieratest.pp":
notice: hello world!
Hurrah! My first hiera-based module!
I don't like hiera, but it's better than hardcoding configuration in .pp files.
First attempt:
vi hieratest.pp
$pippo = hiera('pippo')
notify { "${pippo}" : }
I run "puppet apply hieratest.pp" and I get:
Hiera config file /etc/puppetlabs/puppet/hiera.yaml not readable at /root/puppettests/hieratest.pp:1
then I do vi /etc/puppetlabs/puppet/hiera.yaml and I enter:
:hierarchy:
- hosts/%{::fqdn}
- environments/%{environment}
- common
- users
:backends:
- yaml
:yaml:
:datadir: '/etc/puppetlabs/puppet/hieradata/'
and rerun "puppet apply hieratest.pp" and I get:
Better than before :o)
Could not find data item pippo in any Hiera data file and no default supplied at /root/puppettests/hieratest.pp:1
so I do "mkdir /etc/puppetlabs/puppet/hieradata/" and vi /etc/puppetlabs/puppet/hieradata/common.yaml (remark: common is a member of the hierarchy in the hiera.yaml' and I enter
pippo : 'hello world!'
Again "puppet apply hieratest.pp":
notice: hello world!
Hurrah! My first hiera-based module!