d20860c8ba41ae85d821690fb32f3e5e1f8a76d2
[mirror/dsa-puppet.git] / modules / ipsec / manifests / init.pp.orig
1 # basic ipsec configuration
2 #
3 # this configures all packages and required kernel modules, but
4 # doesn't configure any host, see `ipsec::network` instead.
5 #
6 # when first loaded, this will add a list of modules to the kernel,
7 # but this will only load on reboot.
8 class ipsec {
9   package { [
10     'strongswan',
11     'libstrongswan-standard-plugins'
12   ]:
13     ensure => installed
14   }
15
16   service { 'ipsec':
17     ensure => running,
18   }
19
20   file {
21     '/etc/ipsec.conf':
22       content => template('ipsec/ipsec.conf.erb'),
23       notify  => Service['ipsec'];
24     '/etc/ipsec.secrets':
25       mode    => '0400',
26       content => template('ipsec/ipsec.secrets.erb'),
27       notify  => Service['ipsec'];
28     '/etc/ipsec.conf.d':
29       ensure => 'directory',
30       purge   => true,
31       force   => true,
32       recurse => true,
33       mode   => '0755';
34     '/etc/ipsec.secrets.d':
35       ensure => 'directory',
36       purge   => true,
37       force   => true,
38       recurse => true,
39       mode   => '0700';
40     '/etc/ipsec.conf.d/00-default.conf':
41       content => template('ipsec/ipsec.conf-00-default.conf.erb'),
42       notify  => Service['ipsec'];
43     '/etc/strongswan.d/charon-logging.conf':
44       content => template('ipsec/strongswan-charon-logging.conf'),
45       notify  => Service['ipsec'];
46   }
47
48   ferm::rule {
49     'ipsec-peers':
50       description => 'ipsec protocols are allowed from the ipsec peers',
51       domain      => '(ip ip6)',
52       chain       => 'ipsec-peers',
53       rule        => 'DROP',
54       prio        => 'zzz-999';
55     'ipsec':
56       description => 'ipsec protocols are allowed from the ipsec peers',
57       domain      => '(ip ip6)',
58       rule        => @(EOF),
59                      proto udp dport (isakmp 4500) jump ipsec-peers;
60                      proto esp                     jump ipsec-peers
61                      | EOF
62   }
63
64   # Since we disable module loading after boot, we want to load them all at boot time
65   $modules = split('af_alg af_key ah4 algif_skcipher ansi_cprng authenc drbg echainiv esp4 ipcomp macvlan macvtap tunnel4 vhost vhost_net xfrm4_mode_tunnel xfrm4_tunnel xfrm6_mode_tunnel xfrm_algo xfrm_ipcomp xfrm_user', ' ') # lint:ignore:140chars
66   base::linux_module { $modules: }
67 }