Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.48 KB

hiera-with-control.md

File metadata and controls

47 lines (38 loc) · 1.48 KB

To use Hiera with Puppet, you'll need to set up your Hiera configuration and integrate it into your Puppet control repository. Hiera allows you to separate data from your Puppet manifests, making your configurations more modular and manageable.

Here's a high-level outline:

  1. Set Up Hiera Configuration:
    Create or edit the hiera.yaml file in the root directory of your Puppet control repository. Define the hierarchy and the data format (YAML is common).

    Example:

    ---
    version: 5
    hierarchy:
      - name: "Nodes"
        path: "nodes/%{::trusted.certname}.yaml"
      - name: "Operating System"
        path: "os/%{facts.os.family}.yaml"
      - name: "Common"
        path: "common.yaml"
  2. Store Your Data:
    Organize your data in a directory structure that matches your hierarchy. For example:

    data/
    ├── common.yaml
    ├── nodes/
    │   └── node1.example.com.yaml
    └── os/
        └── RedHat.yaml
    

    Each YAML file should contain key-value pairs for the data you want to use.

  3. Reference Hiera Data in Manifests:
    Use the lookup function in your Puppet manifests to retrieve data from Hiera.

    Example:

    $package_name = lookup('package_name')
    package { $package_name:
      ensure => installed,
    }
  4. Test and Apply:
    Use puppet lookup on the command line to test your Hiera configuration and data retrieval. Once you're satisfied, apply your changes using Puppet.