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