Puppet Class: classroom_legacy::agent::hiera

Inherits:
classroom_legacy::params
Defined in:
manifests/agent/hiera.pp

Overview

Make sure that Hiera is configured for agent nodes so that we can work through the hiera sections without teaching them how to configure it.

Parameters:

  • codedir (Any) (defaults to: $classroom_legacy::params::codedir)
  • confdir (Any) (defaults to: $classroom_legacy::params::confdir)
  • workdir (Any) (defaults to: $classroom_legacy::params::workdir)


4
5
6
7
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'manifests/agent/hiera.pp', line 4

class classroom_legacy::agent::hiera (
  $codedir = $classroom_legacy::params::codedir,
  $confdir = $classroom_legacy::params::confdir,
  $workdir = $classroom_legacy::params::workdir,
) inherits classroom_legacy::params {
  assert_private('This class should not be called directly')

  # Set defaults depending on os
  case $::osfamily {
    'windows' : {
      File {
        owner => 'Administrator',
        group => 'Users',
      }
    }
    default   : {
      File {
        owner => 'pe-puppet',
        group => 'pe-puppet',
        mode  => '0644',
      }
    }
  }

  $hieradata = "${codedir}/hieradata"

  if $classroom_legacy::manage_repos {
    file { $hieradata:
      ensure => link,
      # the hieradata dir is empty so forcing to
      # replace directory with symlink on Win 2012
      force  => true,
      target => "${workdir}/hieradata",
    }

    file { "${confdir}/hiera.yaml":
      ensure => link,
      target => "${workdir}/hiera.yaml",
      force  => true,
    }

    file { "${confdir}/hieradata":
      ensure => link,
      target => "${workdir}/hieradata",
      force  => true,
    }

    file { "${workdir}/hiera.yaml":
      ensure  => file,
      source  => 'puppet:///modules/classroom_legacy/hiera/hiera.agent.yaml',
      replace => false,
    }

  }
  else {
    file { $hieradata:
      ensure => directory,
    }

    # Because PE writes a default, we have to do tricks to see if we've already managed this.
    unless defined('$puppetlabs_class') {
      file { "${confdir}/hiera.yaml":
        ensure  => file,
        source  => 'puppet:///modules/classroom_legacy/hiera/hiera.agent.yaml',
      }
    }
  }

  unless $::osfamily == 'windows' {
    file { '/usr/local/bin/hiera_explain.rb':
      ensure => file,
      owner  => 'root',
      group  => 'root',
      mode   => '0777',
      source => 'puppet:///modules/classroom_legacy/hiera_explain.rb',
    }
  }

  file { "${hieradata}/common.yaml":
    ensure  => file,
    source  => 'puppet:///modules/classroom_legacy/hiera/data/common.yaml',
    replace => false,
  }
}