Book Image

Puppet Cookbook - Third Edition

Book Image

Puppet Cookbook - Third Edition

Overview of this book

Table of Contents (17 chapters)
Puppet Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring Hiera


Hiera is an information repository for Puppet. Using Hiera you can have a hierarchical categorization of data about your nodes that is maintained outside of your manifests. This is very useful for sharing code and dealing with exceptions that will creep into any Puppet deployment.

Getting ready

Hiera should have already been installed as a dependency on your Puppet master. If it has not already, install it using Puppet:

root@puppet:~# puppet resource package hiera ensure=installed
package { 'hiera':
  ensure => '1.3.4-1puppetlabs1',
}

How to do it...

  1. Hiera is configured from a yaml file, /etc/puppet/hiera.yaml. Create the file and add the following as a minimal configuration:

    ---
    :hierarchy:
      - common
    :backends:
      - yaml
    :yaml:
      :datadir: '/etc/puppet/hieradata'
    
  2. Create the common.yaml file referenced in the hierarchy:

    root@puppet:/etc/puppet# mkdir hieradata
    root@puppet:/etc/puppet# vim hieradata/common.yaml
    ---
    message: 'Default Message'
    
  3. Edit the site.pp file and add...