aboutsummaryrefslogtreecommitdiff
path: root/manifests/cert.pp
blob: 14e20054479fe6f1b03914cbdc0180253f87b463 (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
define ssl::cert(
  $ensure   = present,
  $owner    = 'root',
  $group    = 'root',
  $pubmode  = '644',
  $privmode = '600',
  $base     = '/etc/ssl',
  $private  = true,
  $main     = false,
  $check    = 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 ($check == true) {
    ssl::check { "$name":
      file => true,
    }
  }
}