6c694d42c1ac8adc60f221185a940585173e02e3
[puppet_openvpn.git] / manifests / definitions / 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 $scs {
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 }