1

I've got a masterless Puppet setup and I'd like to simply add information such as package names based on $::osfamily for portability. It seems Hiera is made for this sort of thing, but I can't figure out how to actually use Hiera data inside a source repository from a Puppet manifest within the same source repository without modifying anything in /etc. Basically every piece of documentation seems to assume that I'd want to modify /etc/puppetlabs/code/hiera.yaml or /etc/puppetlabs/puppet/puppet.conf by hand whenever I use a different repository. Or am I completely misunderstanding Hiera?

If necessary I'd be OK with adding a puppet.conf to the repository and referencing that every time I run puppet apply, but how would I go about referring to the current directory as the root for the hiera_config?

1 Answer 1

3

Yes, you can use hiera data with masterless setup. Just specify --hiera_config with hiera confiuration which specify where to look for hiera data.

Example:

nkts@trololo:/tmp/puppet$ puppet apply -t --modulepath=./modules/ --hiera_config=./hiera.conf manifests/a.pp Notice: Compiled catalog for trololo.lan in environment production in 0.31 seconds Info: Applying configuration version '1449108414' Notice: test: bar Notice: /Stage[main]/A/Notify[test: bar]/message: defined 'message' as 'test: bar' Notice: Applied catalog in 0.02 seconds nkts@trololo:/tmp/puppet$ cat hiera.conf --- :backends: yaml :yaml: :datadir: /tmp/puppet/data :hierarchy: common :logger: console nkts@trololo:/tmp/puppet$ cat data/common.yaml a::foo: bar nkts@trololo:/tmp/puppet$ cat manifests/a.pp class { "a": } nkts@trololo:/tmp/puppet$ cat modules/a/manifests/init.pp class a ( $foo = "default msg" ){ notify { "test: $foo": } } nkts@trololo:/tmp/puppet$ rm data/common.yaml nkts@trololo:/tmp/puppet$ puppet apply -t --modulepath=./modules/ --hiera_config=./hiera.conf manifests/a.pp Notice: Compiled catalog for trololo.lan in environment production in 0.32 seconds Info: Applying configuration version '1449108454' Notice: test: default msg Notice: /Stage[main]/A/Notify[test: default msg]/message: defined 'message' as 'test: default msg' Notice: Applied catalog in 0.02 seconds nkts@trololo:/tmp/puppet$ 
1
  • Thank you! (I figured it out the meantime :P) Commented Dec 3, 2015 at 2:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.