5

The documentation for hiera on docs.puppetlabs.com seems to give me the impression that I can use puppet syntax to describe my data. Or posssibly will be able to in the future. See: Coming soon.

Is this functionality present in a release version of puppet, and just not documented, or is this still being developed? If this functionality is present, does anyone have examples of how to actually use this?

The presence of the puppet_backend.rb file on my system gives which was part of the puppetmaster package makes me thing that this functionality is present, but just not documented. So I am trying to figure out how to actually use this.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • Good question -- some of the `hiera.yaml` examples I've seen in the docs have the `puppet` backend set. I'm not sure how that's supposed to work though. – Shane Madden Oct 21 '13 at 17:29

1 Answers1

2

This post on the puppet-users mailing list describes the basic usage.

Rewritten with a more complete example, with Hierarchy:

Given a hiera.yaml like this:

:backends:
  - puppet
:puppet:
  :datasource: data
:hierarchy:
  - %{osfamily}::%{operatingsystem}::%{architecture}
  - %{osfamily}::%{operatingsystem}
  - %{osfamily}
  - global

And given a simple class within a module:

class foo::bar {
  $baz = hiera('baz')
}

The backend will look for a class containing the variable $baz in the following order:

data::RedHat::CentOS::x86_64
data::RedHat::CentOS
data::RedHat
data::global
foo::bar::data
foo::data

The default datasource name is data, but that can be customized. Given klaatu, it would search:

klaatu::RedHat::CentOS::x86_64
klaatu::RedHat::CentOS
klaatu::RedHat
klaatu::global
foo::bar::klaatu
foo::klaatu

The last two appear to be added regardless of the hierarchy, and always in the format of %{calling_class}::%{datasource} and %{calling_module}::%{datasource}.

There appear to be limits to what sorts of facts you can use in these hierarchies vs. a yaml backend. For example, %{clientcert} won't be usable since dots are not allowed in class names.

Cakemox
  • 24,141
  • 6
  • 41
  • 67
  • The update answer looks great. I won't have a chance to test before the bounty expires, so I am going to assume that this correct for now. – Zoredache Oct 31 '13 at 18:09