summaryrefslogtreecommitdiff
path: root/puppet/modules/x509/manifests/cert.pp
blob: 0aafb76d30e8e5277d6328f1a95d89a453846342 (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
define x509::cert (
  $content = 'absent',
  $source  = 'absent'
) {
  include x509::variables
  include x509::base

  file { "${x509::variables::certs}/${name}.crt":
    ensure  => file,
    mode    => '0444',
    group   => 'ssl-cert',
    require => Package['ssl-cert']
  }

  case $content {
    'absent': {
      $real_source = $source ? {
        'absent' => [
                     "puppet:///modules/site_x509/certs/${::fqdn}/${name}.crt",
                     "puppet:///modules/site_x509/certs/${name}.crt"
                     ],
        default => "puppet:///$source",
      }
      File["${x509::variables::certs}/${name}.crt"] {
        source => $real_source
      }
    }
    default: {
      File["${x509::variables::certs}/${name}.crt"] {
        content => $content
      }
    }
  }
}