]> xn--ix-yja.es Git - alex.git/commitdiff
Make tinc host file generation less noisy
authoralex <alex@pdp7.net>
Sun, 15 Jan 2023 12:25:04 +0000 (13:25 +0100)
committeralex <alex@pdp7.net>
Sun, 15 Jan 2023 12:25:04 +0000 (13:25 +0100)
personal_infra/puppet/modules/tinc/manifests/init.pp

index 9f1ab0b601e54fd05a31edcae12bc2c50378a6cc..fc70a31c08f6c20763fc1a5bd1002e2ab56c863b 100644 (file)
@@ -22,9 +22,22 @@ class tinc($tinc_name, $tinc_location, $tinc_connect_to, $tinc_locations, $tinc_
   }
 
   $tinc_locations.each |$name, $location| {
-    exec {"/bin/echo Subnet = ${location['subnet']} >/etc/tinc/${tinc_name}/hosts/${name} && echo Address = ${location['address']} >>/etc/tinc/${tinc_name}/hosts/${name} ; cat /etc/ansible/tinc/public_${location['address']}.pem >>/etc/tinc/${tinc_name}/hosts/${name}":
+    file {"/etc/tinc/${tinc_name}/generate_host_${name}.sh":
+      content => "#!/bin/sh
+
+set -ue
+
+echo Subnet = ${location['subnet']} >/etc/tinc/${tinc_name}/hosts/${name}
+echo Address = ${location['address']} >>/etc/tinc/${tinc_name}/hosts/${name}
+cat /etc/ansible/tinc/public_${location['address']}.pem >>/etc/tinc/${tinc_name}/hosts/${name}
+      ",
+      mode => '755',
+    }
+    ~> 
+    exec {"/etc/tinc/${tinc_name}/generate_host_${name}.sh":
       require => File["/etc/tinc/${tinc_name}/hosts"],
       notify => Service["tinc@${tinc_name}"],
+      creates => "/etc/tinc/${tinc_name}/hosts/${name}",
     }
   }