8c2a7a28a34f6a13022596142a7b439ea8df2d86
[puppet_openvpn.git] / manifests / option.pp
1 # option.pp
2
3 define openvpn::option($ensure = present, $key, $value = "", $server, $client = "", $csc = false) {
4     $content = $value ? {
5         ""      => "${key}",
6         default => "${key} ${value}"
7     }
8
9     if $client == "" {
10         $path = "/etc/openvpn/${server}.conf"
11         $req = File["/etc/openvpn"]
12         $notify  = Service["openvpn"]
13     } else {
14         if $csc {
15             $path = "/etc/openvpn/${server}/client-configs/${client}"
16         } else {
17             $path = "/etc/openvpn/${server}/download-configs/${client}/${client}.conf"
18         }
19         $req = [ File["/etc/openvpn"], File["/etc/openvpn/${server}/download-configs/${client}"] ]
20         $notify = undef
21     }
22
23     common::concatfilepart {
24         "${name}":
25             ensure  => $ensure,
26             file    => $path,
27             content => "${content}\n",
28             notify  => $notify,
29             require => $req;
30     }
31 }