File: config.pp

package info (click to toggle)
puppet-module-puppet 18.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 660 kB
  • sloc: ruby: 2,055; sh: 15; makefile: 10
file content (103 lines) | stat: -rw-r--r-- 3,315 bytes parent folder | download
1
2
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
# Set up the puppet config
# @api private
class puppet::config (
  # lint:ignore:parameter_types
  $allow_any_crl_auth    = $puppet::allow_any_crl_auth,
  $auth_allowed          = $puppet::auth_allowed,
  $ca_server             = $puppet::ca_server,
  $ca_port               = $puppet::ca_port,
  $dns_alt_names         = $puppet::dns_alt_names,
  $module_repository     = $puppet::module_repository,
  $pluginsource          = $puppet::pluginsource,
  $pluginfactsource      = $puppet::pluginfactsource,
  $puppet_dir            = $puppet::dir,
  $agent_server_hostname = $puppet::agent_server_hostname,
  $syslogfacility        = $puppet::syslogfacility,
  $srv_domain            = $puppet::srv_domain,
  $use_srv_records       = $puppet::use_srv_records,
  $additional_settings   = $puppet::additional_settings,
  $client_certname       = $puppet::client_certname,
  # lint:endignore
) {
  puppet::config::main {
    'vardir': value => $puppet::vardir;
    'logdir': value => $puppet::logdir;
    'rundir': value => $puppet::rundir;
    'ssldir': value => $puppet::ssldir;
    'privatekeydir': value => '$ssldir/private_keys { group = service }';
    'hostprivkey': value => '$privatekeydir/$certname.pem { mode = 640 }';
    'show_diff': value  => $puppet::show_diff;
    'codedir': value => $puppet::codedir;
  }

  if $module_repository and !empty($module_repository) {
    puppet::config::main { 'module_repository': value => $module_repository; }
  }
  if $ca_server and !empty($ca_server) {
    puppet::config::main { 'ca_server': value => $ca_server; }
  }
  if $ca_port {
    puppet::config::main { 'ca_port': value => $ca_port; }
  }
  if $dns_alt_names and !empty($dns_alt_names) {
    puppet::config::main { 'dns_alt_names': value => $dns_alt_names; }
  }
  if $use_srv_records {
    unless $srv_domain {
      fail('domain fact found to be undefined and $srv_domain is undefined')
    }
    puppet::config::main {
      'use_srv_records': value => true;
      'srv_domain': value => $srv_domain;
    }
  } else {
    puppet::config::main {
      'server': value => pick($agent_server_hostname, $facts['networking']['fqdn']);
    }
  }
  if $pluginsource {
    puppet::config::main { 'pluginsource': value => $pluginsource; }
  }
  if $pluginfactsource {
    puppet::config::main { 'pluginfactsource': value => $pluginfactsource; }
  }
  if $syslogfacility and !empty($syslogfacility) {
    puppet::config::main { 'syslogfacility': value => $syslogfacility; }
  }
  if $client_certname {
    puppet::config::main {
      'certname': value => $client_certname;
    }
  }

  $additional_settings.each |$key,$value| {
    puppet::config::main { $key: value => $value }
  }

  concat::fragment { 'puppet.conf_comment':
    target  => "${puppet_dir}/puppet.conf",
    content => '# file managed by puppet',
    order   => '0_comment',
  }

  file { $puppet_dir:
    ensure => directory,
    owner  => $puppet::dir_owner,
    group  => $puppet::dir_group,
  }
  -> case $facts['os']['family'] {
    'Windows': {
      concat { "${puppet_dir}/puppet.conf":
        mode  => $puppet::puppetconf_mode,
      }
    }

    default: {
      concat { "${puppet_dir}/puppet.conf":
        owner => 'root',
        group => $puppet::params::root_group,
        mode  => $puppet::puppetconf_mode,
      }
    }
  }
}