Puppet Class: puppet::server::bootstrap::hiera

Inherits:
puppet::params
Defined in:
manifests/server/bootstrap/hiera.pp

Summary

Bootstrap Hiera

Overview

Bootstrap Hiera from current directory into production environment This is intended to be run via ‘puppet apply` command

Examples:

include puppet::server::bootstrap::hiera


8
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
43
44
45
46
47
# File 'manifests/server/bootstrap/hiera.pp', line 8

class puppet::server::bootstrap::hiera inherits puppet::params {
  require puppet::server::install

  $environmentpath = $puppet::params::environmentpath

  # default production environment
  $env_path = "${environmentpath}/production"
  $data_path = "${env_path}/data"

  file { [$environmentpath, $env_path, $data_path]:
    ensure  => 'directory',
    require => Class['puppet::server::install'],
  }

  exec {
    default:
      path => '/usr/bin:/bin';
    "cp -a hiera.yaml ${env_path}/hiera.yaml":
      onlyif  => 'test -f hiera.yaml',
      unless  => "grep -q secrets.eyaml ${env_path}/hiera.yaml",
      require => File[$env_path],
      before  => File["${env_path}/hiera.yaml"],
      ;
    "cp -a data/secrets.eyaml ${data_path}/secrets.eyaml":
      onlyif  => 'test -f data/secrets.eyaml',
      creates => "${data_path}/secrets.eyaml",
      require => File[$data_path],
      before  => File["${data_path}/secrets.eyaml"],
      ;
  }

  file {
    default:
      mode  => '0440',
      group => 'puppet',
      ;
    "${env_path}/hiera.yaml": ;
    "${data_path}/secrets.eyaml": ;
  }
}