Puppet Class: puppet::master::config

Defined in:
manifests/master/config.pp

Overview



3
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'manifests/master/config.pp', line 3

class puppet::master::config {
  include ::puppet::master
  include ::puppet::defaults
  $confdir              = $::puppet::defaults::confdir
  $codedir              = $::puppet::defaults::codedir
  $reports_dir          = $::puppet::defaults::reports_dir
  $ca_server            = $::puppet::ca_server
  $autosign_method      = $::puppet::master::autosign_method
  $autosign_file        = $::puppet::master::autosign_file
  $autosign_domains     = $::puppet::master::autosign_domains
  $environmentpath      = $puppet::master::environmentpath
  $environment_timeout  = $puppet::master::environment_timeout
  $basemodulepath       = $puppet::master::basemodulepath
  $future_parser        = $puppet::master::future_parser
  $autosign             = $puppet::master::autosign
  $report_age           = $puppet::master::report_age
  $report_clean_hour    = $puppet::master::report_clean_hour
  $report_clean_min     = $puppet::master::report_clean_min
  $report_clean_weekday = $puppet::master::report_clean_weekday
  $external_nodes       = $puppet::master::external_nodes
  $node_terminus        = $puppet::master::node_terminus

  if ($ca_server != undef) {
    if ($ca_server == $::fqdn) {
      ini_setting { 'puppet CA':
        ensure  => present,
        path    => "${confdir}/puppet.conf",
        section => 'master',
        setting => 'ca',
        value   => true,
      }
    } else {
      ini_setting { 'puppet CA':
        ensure  => present,
        path    => "${confdir}/puppet.conf",
        section => 'master',
        setting => 'ca',
        value   => false,
      }
    }
  }

  # setup autosign and autosign file
  case $autosign_method {
    default,'file': {
      $autosign_value = $autosign_file
    }
    'off': {
      $autosign_value = false
    }
    'on': {
      if $::environment == 'production' {
        $autosign_value = false
      } else {
        $autosign_value = true
      }
    }
  }

  # setup autosign
  ini_setting { 'autosign':
    ensure  => present,
    path    => "${confdir}/puppet.conf",
    section => 'master',
    setting => 'autosign',
    value   => $autosign_value
  }

  if (! empty($autosign_domains) ) {
    file { $autosign_file:
      ensure  => file,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template('puppet/autosign.conf.erb')
    }
  }

  ini_setting { 'Puppet environmentpath':
    ensure  => present,
    path    => "${confdir}/puppet.conf",
    section => 'main',
    setting => 'environmentpath',
    value   => $environmentpath
  }

  ini_setting { 'Puppet basemodulepath':
    ensure  => present,
    path    => "${confdir}/puppet.conf",
    section => 'main',
    setting => 'basemodulepath',
    value   => $basemodulepath
  }

  ini_setting { 'Puppet environment_timeout':
    ensure  => present,
    path    => "${confdir}/puppet.conf",
    section => 'main',
    setting => 'environment_timeout',
    value   => $environment_timeout
  }

  # cleanup old puppet reports
  cron { 'puppet clean reports':
    command => "if test -x ${reports_dir}; then cd ${reports_dir} && find . -type f -name \\*.yaml -mtime +${report_age} -print0 | xargs -0 -n50 /bin/rm -f; fi",
    user    => root,
    hour    => $report_clean_hour,
    minute  => $report_clean_min,
    weekday => $report_clean_weekday,
  }

  if $future_parser {
    # enable future parser
    ini_setting { 'master parser':
      ensure  => present,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'parser',
      value   => 'future'
    }
  } else {
    # disable future parser
    ini_setting { 'master parser':
      ensure  => absent,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'parser',
      value   => 'future'
    }
  }

  if ( $external_nodes != undef and $node_terminus != undef ){
    # enable external_nodes
    ini_setting { 'master external_nodes':
      ensure  => present,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'external_nodes',
      value   => $external_nodes,
    }
    ini_setting { 'master node_terminus':
      ensure  => present,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'node_terminus',
      value   => $node_terminus,
    }
  } else {
    # disable external_nodes
    ini_setting { 'master external_nodes':
      ensure  => absent,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'external_nodes',
    }
    ini_setting { 'master node_terminus':
      ensure  => absent,
      path    => "${confdir}/puppet.conf",
      section => 'master',
      setting => 'node_terminus',
    }
  }

}