]> WPIA git - infra.git/commitdiff
chg: extract lxc-bind-mounts to own resources
authorFelix Dörre <felix@dogcraft.de>
Sat, 22 Dec 2018 12:19:13 +0000 (13:19 +0100)
committerFelix Dörre <felix@dogcraft.de>
Sun, 23 Dec 2018 09:22:24 +0000 (10:22 +0100)
Change-Id: Iaf0e30fa582131d02488f6cda44f416d729f78c9

modules/lxc/manifests/init.pp

index 0f4101d8da7aa7dfad0d53aae5190dcfee28e7d3..3693966f0f0ef965356efe63692dc0a2929880ef 100644 (file)
@@ -23,6 +23,20 @@ class lxc {
       refreshonly => true,
       subscribe => File['/etc/network/interfaces.d/lxcbr0']
     }
       refreshonly => true,
       subscribe => File['/etc/network/interfaces.d/lxcbr0']
     }
+    
+    define container_bind($container, $out = $name, $target, $option = ""){
+      file{"/var/lib/lxc/$container/rootfs/$target":
+        ensure => directory,
+        require => File_line["lxc-$container-conf5"],
+        before => Exec["lxc-$container-started"]
+      }->
+      file_line { "lxc-$container-mount-$out":
+        path   => "/var/lib/lxc/$container/config",
+        line   => "lxc.mount.entry = $out $target none bind$option 0 0",
+        require=> [File_line["lxc-$container-conf5"], File["$out"]],
+        notify  => Exec["lxc-$container-started"],
+      }
+    }
     define container ($contname, $ip, $dir = [], $bind = {}, $confline = []) {
         exec {"lxc-$contname-issue-cert":
           command => "/usr/bin/puppet ca destroy \"$contname\";/usr/bin/puppet ca generate \"$contname\"",
     define container ($contname, $ip, $dir = [], $bind = {}, $confline = []) {
         exec {"lxc-$contname-issue-cert":
           command => "/usr/bin/puppet ca destroy \"$contname\";/usr/bin/puppet ca generate \"$contname\"",