Puppet Class: classroom::agent::hiera

Inherits:
classroom::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::params::codedir)
  • confdir (Any) (defaults to: $classroom::params::confdir)
  • workdir (Any) (defaults to: $classroom::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
# File 'manifests/agent/hiera.pp', line 4

class classroom::agent::hiera (
  $codedir = $classroom::params::codedir,
  $confdir = $classroom::params::confdir,
  $workdir = $classroom::params::workdir,
) inherits classroom::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"
  
  # ensure we've got a target to point our shortcuts to
  dirtree { "${workdir}/hieradata":
    ensure  => present,
    parents => true,
  }
 
  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/hiera/hiera.agent.yaml',
    replace => false,
  }


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

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