summaryrefslogtreecommitdiff
path: root/manifests/cert.pp
blob: 6b9f685053b30ffdcd528dd160d7acf420b76fe0 (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
# manage a cert snippet that we want to include
define strongswan::cert (
  $ensure = 'present',
  $cert   = 'absent'
) {
  if ($cert == 'absent') and ($ensure == 'present'){
    fail("You need to pass some \$cert content for ${name} if it should be present")
  }

  file { "${strongswan::cert_dir}/certs/${name}.asc":
    ensure  => $ensure,
    require => Package['strongswan'],
    notify  => Service['ipsec'],
  }

  if $ensure == 'present' {
    File["${strongswan::cert_dir}/certs/${name}.asc"]{
      content => $cert,
      owner   => 'root',
      group   => 0,
      mode    => '0400',
    }
  }
}