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

  file { "${x509::variables::local_CAs}/${name}.crt" :
    ensure  => file,
    mode    => '0444',
    group   => 'ssl-cert',
    require => Package['ca-certificates'],
    notify  => Exec['update-ca-certificates'],
  }
  case $content {
    'absent': {
      $real_source = $source ? {
        'absent' => [
                     "puppet:///modules/site_x509/CAs/${::fqdn}/${name}.crt",
                     "puppet:///modules/site_x509/CAs/${name}.crt"
                     ],
        default => "puppet:///$source",
      }
      File["${x509::variables::local_CAs}/${name}.crt"] {
        source => $real_source
      }
    }
    default: {
      File["${x509::variables::local_CAs}/${name}.crt"] {
        content => $content
      }
    }
  }
}