summaryrefslogtreecommitdiff
path: root/manifests/remote_host.pp
blob: 059d96923da0fd2fe3a925a7b42b1da1ef3c9ce4 (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
38
39
# configure a simple remote host
define strongswan::remote_host(
  $right_ip_address,
  $right_subnet       = [],
  $ensure             = 'present',
  $left_id            = 'absent',
  $left_ip_address    = 'absent',
  $left_subnet        = [],
  $right_id           = $name,
  $right_cert_name    = $name,
  $right_cert_content = 'absent'
){
  file{"${strongswan::config_dir}/hosts/${name}.conf":
    ensure  => $ensure,
    require => Package['strongswan'],
    notify  => Service['ipsec'],
  }

  if $ensure == 'present' {
    File["${strongswan::config_dir}/hosts/${name}.conf"]{
      content => template('strongswan/remote_host.erb'),
      owner   => 'root',
      group   => 0,
      mode    => '0400',
    }
  }

  strongswan::cert{$name: }
  if ($right_cert_content != 'absent') and ($ensure == 'present') {
    Strongswan::Cert[$name]{
      ensure  => $ensure,
      cert    => $right_cert_content,
    }
  } else {
    Strongswan::Cert[$name]{
      ensure => 'absent',
    }
  }
}