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
48
49
50
51
52
53
54
55
56
57
58
# File 'manifests/server/bootstrap/hiera.pp', line 8

class puppet::server::bootstrap::hiera inherits puppet::params {
  require puppet::server::install
  include puppet::server::bootstrap::globals
  include puppet::server::bootstrap::setup
  include puppet::server::setup::filesystem

  $environmentpath = $puppet::params::environmentpath
  $cwd = $puppet::server::bootstrap::globals::cwd

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

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

  exec {
    default:
      path    => '/usr/bin:/bin',
      cwd     => $cwd,
      require => [
        File[$data_path],
        Class['puppet::server::bootstrap::setup'],
      ],
      ;
    "cp -a hiera/common.yaml ${data_path}/common.yaml":
      onlyif => 'test -f hiera/common.yaml',
      unless => "diff -q hiera/common.yaml ${data_path}/common.yaml",
      before => File["${data_path}/common.yaml"],
      ;
    "cp -a hiera/secrets.eyaml ${data_path}/secrets.eyaml":
      onlyif => 'test -f hiera/secrets.eyaml',
      unless => "diff -q hiera/secrets.eyaml ${data_path}/secrets.eyaml",
      before => File["${data_path}/secrets.eyaml"],
      ;
  }

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