update module to use concat instead of concatfilepart
authorRaffael Schmid <raffael@yux.ch>
Fri, 10 Feb 2012 16:49:28 +0000 (17:49 +0100)
committerRaffael Schmid <raffael@yux.ch>
Fri, 10 Feb 2012 16:49:28 +0000 (17:49 +0100)
manifests/client.pp
manifests/init.pp
manifests/option.pp
manifests/server.pp

index 4e443e4..82e498a 100644 (file)
@@ -121,10 +121,22 @@ define openvpn::client($server, $remote_host = $fqdn) {
             cwd         => "/etc/openvpn/${server}/download-configs/",
             command     => "rm ${name}.tar.gz; tar --exclude=\\*.conf.d -chzvf ${name}.tar.gz ${name}",
             refreshonly => true,
-            subscribe   => Exec["/etc/openvpn/${server}/download-configs/${name}/${name}.conf concatenation"],
             require     => [ File["/etc/openvpn/${server}/download-configs/${name}/${name}.conf"],
                             File["/etc/openvpn/${server}/download-configs/${name}/keys/ca.crt"],
                             File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.key"],
                             File["/etc/openvpn/${server}/download-configs/${name}/keys/${name}.crt"] ];
     }
+
+
+    concat {
+        [ "/etc/openvpn/${server}/client-configs/${name}", "/etc/openvpn/${server}/download-configs/${name}/${name}.conf" ]:
+            owner   => root,
+            group   => root,
+            mode    => 644,
+            warn    => true,
+            force   => true,
+            notify  => Exec["tar the thing ${server} with ${name}"],
+            require => [ File["/etc/openvpn"], File["/etc/openvpn/${server}/download-configs/${name}"] ];
+    }
+
 }
index 55dac85..7e7fe32 100644 (file)
@@ -10,7 +10,7 @@ class openvpn {
             ensure     => running,
             hasrestart => true,
             hasstatus  => true,
-            require    => Exec["/etc/default/openvpn concatenation"];
+            require    => Exec["concat_/etc/default/openvpn"];
     }
     file {
         "/etc/openvpn":
@@ -22,11 +22,23 @@ class openvpn {
             ensure  => directory,
             require => File["/etc/openvpn"];
     }
-    common::concatfilepart {
-        "00-etc-default-openvpn header":
-            ensure  => present,
+
+    include concat::setup
+
+    concat {
+        "/etc/default/openvpn":
+            owner  => root,
+            group  => root,
+            mode   => 644,
+            warn   => true,
+            notify => Service["openvpn"];
+    }
+
+    concat::fragment {
+        "openvpn.default.header":
             content => template("openvpn/etc-default-openvpn.erb"),
-            notify  => Service["openvpn"],
-            file    => "/etc/default/openvpn";
+            target  => "/etc/default/openvpn",
+            order   => 01;
     }
+
 }
index 8c2a7a2..5cadb31 100644 (file)
@@ -1,6 +1,6 @@
 # option.pp
 
-define openvpn::option($ensure = present, $key, $value = "", $server, $client = "", $csc = false) {
+define openvpn::option($key, $value = "", $server, $client = "", $csc = false) {
     $content = $value ? {
         ""      => "${key}",
         default => "${key} ${value}"
@@ -8,24 +8,17 @@ define openvpn::option($ensure = present, $key, $value = "", $server, $client =
 
     if $client == "" {
         $path = "/etc/openvpn/${server}.conf"
-        $req = File["/etc/openvpn"]
-        $notify  = Service["openvpn"]
     } else {
         if $csc {
             $path = "/etc/openvpn/${server}/client-configs/${client}"
         } else {
             $path = "/etc/openvpn/${server}/download-configs/${client}/${client}.conf"
         }
-        $req = [ File["/etc/openvpn"], File["/etc/openvpn/${server}/download-configs/${client}"] ]
-        $notify = undef
     }
 
-    common::concatfilepart {
-        "${name}":
-            ensure  => $ensure,
-            file    => $path,
-            content => "${content}\n",
-            notify  => $notify,
-            require => $req;
+    concat::fragment {
+        "openvpn.${server}.${client}.${name}":
+            target  => $path,
+            content => "${content}\n";
     }
 }
index 2bf2f64..b279b02 100644 (file)
@@ -29,7 +29,7 @@ define openvpn::server($country, $province, $city, $organization, $email) {
             content => template("openvpn/vars.erb"),
             require => Exec["copy easy-rsa to openvpn config folder ${name}"];
     }
-    
+
     exec {
         "generate dh param ${name}":
             command  => ". ./vars && ./clean-all && ./build-dh",
@@ -37,14 +37,14 @@ define openvpn::server($country, $province, $city, $organization, $email) {
             creates  => "/etc/openvpn/${name}/easy-rsa/keys/dh1024.pem",
             provider => "shell",
             require  => File["/etc/openvpn/${name}/easy-rsa/vars"];
-        
+
         "initca ${name}":
             command  => ". ./vars && ./pkitool --initca",
             cwd      => "/etc/openvpn/${name}/easy-rsa",
             creates  => "/etc/openvpn/${name}/easy-rsa/keys/ca.key",
             provider => "shell",
             require  => Exec["generate dh param ${name}"];
-        
+
         "generate server cert ${name}":
             command  => ". ./vars && ./pkitool --server server",
             cwd      => "/etc/openvpn/${name}/easy-rsa",
@@ -82,11 +82,22 @@ define openvpn::server($country, $province, $city, $organization, $email) {
             require => Exec["generate dh param ${name}"],
             server  => "${name}";
     }
-    
-    common::concatfilepart {
-        "etc-default-openvpn autostart for ${name}":
-            ensure  => present,
+
+    concat::fragment {
+        "openvpn.default.autostart.${name}":
             content => "AUTOSTART=\"\$AUTOSTART ${name}\"\n",
-            file    => "/etc/default/openvpn";
+            target  => "/etc/default/openvpn",
+            order   => 10;
+    }
+
+    concat {
+        "/etc/openvpn/${name}.conf":
+            owner   => root,
+            group   => root,
+            mode    => 644,
+            warn    => true,
+            require => File["/etc/openvpn"],
+            notify  => Service["openvpn"];
     }
+
 }