aboutsummaryrefslogtreecommitdiff
path: root/manifests/cert.pp
blob: f9d916d717f30a6fb07bcf75f2a5e263bd1c38c1 (plain)
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
define ssl::cert(
  $ensure   = present,
  $owner    = 'root',
  $group    = 'root',
  $pubmode  = '644',
  $privmode = '600',
  $base     = '/etc/ssl',
  $private  = true,
  $main     = false,
  $verify   = true,
) {
  file { "${base}/certs/${name}.crt":
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => $pubmode,
    source  => "puppet:///ssl/${name}.crt",
    require => File["${base}/certs"],
  }

  if ($private == true) {
    file { "${base}/private/$name.pem":
      ensure  => $ensure,
      owner   => $owner,
      group   => $group,
      mode    => $privmode,
      backup  => false, # Do not backup the private key
      source  => "puppet:///ssl/${name}.pem",
      require => File["${base}/private"],
    }
  }

  if ($main == true) {
    file { "${base}/certs/cert.crt":
      ensure => "${base}/certs/${name}.crt",
    }

    file { "${base}/private/cert.pem":
      ensure => "${base}/private/${name}.pem",
    }
  }

  if ($verify == true) {
    ssl::check { "${name}":
      file => true,
      base => $base,
    }
  }
}