summaryrefslogtreecommitdiff
path: root/manifests/ca.pp
blob: bd39662a4c2c072c68da7adfac9a8ab33a3a224d (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['openssl'], 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
      }
    }
  }
}