Hiera

From Kyle's Wiki
Jump to: navigation, search

Contents

hiera.yaml

Start off with the basic hiera.yaml in either /etc/puppet/hiera.yaml or ~/.puppet/hiera.yaml

---
:backends: yaml
:yaml:
  :datadir: /etc/puppet/hieradata
:hierarchy: 
  - "%{::clientcert}"
  - common

Warning: Only use facts when constructing your hiera hierarchy to ensure predictable results.

Making Hiera yaml override files

Create yaml files, at least the common.yaml file in the hieradata folder:

---
dns::client::resolvers:
 - '4.2.2.2'
 - '8.8.8.8'

dns::server::masters:
 - '1.2.3.4'
 - '2.4.5.6'

random_config: true

Using Hiera data

Ask for variables in puppet via explicit request

    class myclass (
      $parameter_one = hiera('myclass::parameter_one', 'default text')
    ) {

Use scope.function_hiera( in erb templates

(not recommended)

Use Automatic Lookups in Puppet 3 or later

 
class myclass (
  $param_one = 'default'
) {

If there is hiera data somewhere like:

myclass::param_one: 'othervalue'

othervalue will be automatically used!

Personal tools
Namespaces

Variants
Actions
Efforts
Toolbox
Meta