Puppet Plan: cd4peadm::install::create_hiera_config

Defined in:
plans/install/create_hiera_config.pp

Summary

Generates a Hiera config file

Overview

Parameters:

  • hiera_config_file_path (String) (defaults to: 'hiera.yaml')

    Determines where the Hiera config file is written.

  • hiera_data_file_path (String) (defaults to: 'data/common.yaml')

    Determines where the CD4PE config is written.

  • pkcs7_private_key_path (String) (defaults to: 'keys/private_key.pkcs7.pem')

    Path to the private key used to decrypt Hiera data encrypted with eyaml.

  • pkcs7_public_key_path (String) (defaults to: 'keys/public_key.pkcs7.pem')

    Path to the public key used to encrypt Hiera data with eyaml.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'plans/install/create_hiera_config.pp', line 9

plan cd4peadm::install::create_hiera_config(
  String $hiera_config_file_path = 'hiera.yaml',
  String $hiera_data_file_path = 'data/common.yaml',
  String $pkcs7_private_key_path = 'keys/private_key.pkcs7.pem',
  String $pkcs7_public_key_path = 'keys/public_key.pkcs7.pem',
) {
  out::message('Checking if hiera.yaml exists for Bolt project')
  $hiera_absolute_path = file::join(cd4peadm::bolt_project_dir(), $hiera_config_file_path)
  if file::exists($hiera_absolute_path) {
    out::message("Found existing configuration at '${hiera_absolute_path}', skipping creation")
  } else {
    $hiera_config = {
      'version'   => 5,
      'defaults'  => {
        'datadir'   => cd4peadm::file_dirname($hiera_data_file_path),
        'data_hash' => 'yaml_data',
      },
      'hierarchy' => [{
          'name'       => 'common',
          'lookup_key' => 'eyaml_lookup_key',
          'options'    => {
            'pkcs7_private_key' => $pkcs7_private_key_path,
            'pkcs7_public_key'  => $pkcs7_public_key_path,
          },
          'paths'      => [
            'common.yaml',
          ],
      }],
    }

    $hiera_config_path = cd4peadm::save_yaml_file($hiera_config, $hiera_config_file_path)
    out::message("Saved Hiera config file to ${hiera_config_path}")
  }
}