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

  file { "${x509::variables::keys}/${name}.key":
    ensure  => file,
    mode    => '0640',
    owner   => $owner,
    group   => $group,
    require => Package['ssl-cert']
  }

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