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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
bundle agent openvpn
{
vars:
any::
"tunnels" slist => getindices("g.host_data[tunnels]");
files:
any::
"/etc/openvpn/common.key"
create => "true",
edit_defaults => empty,
perms => system_owned("440"),
copy_from => local_dcp("$(sys.inputdir)/templates/openvpn/common.key.cftpl"),
classes => if_repaired("openvpn_common_key_repaired");
methods:
any::
"any" usebundle => install_package("$(this.bundle)", "openvpn");
"any" usebundle => openvpn_tunnel("$(tunnels)");
services:
linux::
"openvpn@$(tunnels)"
service_policy => "start",
classes => if_repaired("tunnel_$(tunnels)_service_repaired");
commands:
any::
"/usr/sbin/service openvpn@$(tunnels) restart" classes => if_repaired("tunnel_$(tunnels)_service_repaired"), ifvarclass => "openvpn_common_key_repaired";
reports:
any::
"$(this.bundle): common.key repaired" ifvarclass => "openvpn_common_key_repaired";
"$(this.bundle): $(tunnels) service repaired" ifvarclass => "tunnel_$(tunnels)_service_repaired";
}
bundle agent openvpn_tunnel(tunnel)
{
classes:
any::
"has_remote" and => { isvariable("g.host_data[tunnels][$(tunnel)][remote_host]"), isvariable("g.host_data[tunnels][$(tunnel)][remote_port]") };
files:
any::
"/etc/openvpn/$(tunnel).conf"
create => "true",
edit_defaults => empty,
perms => system_owned("440"),
edit_template => "$(sys.inputdir)/templates/openvpn/tunnel.conf.cftpl",
template_method => "cfengine",
classes => if_repaired("openvpn_$(tunnel)_conf_repaired");
commands:
any::
"/usr/sbin/service openvpn@$(tunnel) restart" classes => if_repaired("tunnel_$(tunnel)_service_repaired"), ifvarclass => "openvpn_$(tunnel)_conf_repaired";
reports:
any::
"$(this.bundle): $(tunnel).conf repaired" ifvarclass => "openvpn_$(tunnel)_conf_repaired";
"$(this.bundle): $(tunnel) service repaired" ifvarclass => "tunnel_$(tunnel)_service_repaired";
}
|