]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Change host_ldap to concat
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 14 Aug 2018 20:49:29 +0000 (22:49 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 17 Aug 2018 10:50:25 +0000 (12:50 +0200)
modules/base_installation/manifests/puppet.pp
modules/base_installation/templates/puppet/host_ldap_add_top.info.erb [moved from modules/base_installation/templates/puppet/host_ldap.info.erb with 51% similarity]
modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb [new file with mode: 0644]

index 05fe9a1f2f45fd4b264008e6da91981ff705839e..10b3773041bd7b54356243546340eb76f2c1f05c 100644 (file)
@@ -109,10 +109,34 @@ class base_installation::puppet (
     }
 
     $ips = lookup("ips", { 'default_value' => undef })
-    file { "$base_installation::puppet_conf_path/host_ldap.info":
-      content => template("base_installation/puppet/host_ldap.info.erb"),
-      require => File[$base_installation::puppet_conf_path],
-      notify  => Notify_refresh["notify-ldap-password"],
+    concat { "$base_installation::puppet_conf_path/host_ldap.info":
+      ensure         => "present",
+      mode           => "0600",
+      require        => File[$base_installation::puppet_conf_path],
+      notify         => Notify_refresh["notify-ldap-password"],
+      ensure_newline => true,
+    }
+
+    concat::fragment { "host_ldap add top":
+      target  => "$base_installation::puppet_conf_path/host_ldap.info",
+      content => template("base_installation/puppet/host_ldap_add_top.info.erb"),
+      order   => "00-01",
+    }
+    concat::fragment { "host_ldap add bottom":
+      target  => "$base_installation::puppet_conf_path/host_ldap.info",
+      content => "EOF",
+      order   => "00-99",
+    }
+
+    concat::fragment { "host_ldap mod top":
+      target  => "$base_installation::puppet_conf_path/host_ldap.info",
+      content => template("base_installation/puppet/host_ldap_mod_top.info.erb"),
+      order   => "01-01",
+    }
+    concat::fragment { "host_ldap mod bottom":
+      target  => "$base_installation::puppet_conf_path/host_ldap.info",
+      content => "EOF",
+      order   => "01-99",
     }
 
     notify_refresh { "notify-ldap-password":
similarity index 51%
rename from modules/base_installation/templates/puppet/host_ldap.info.erb
rename to modules/base_installation/templates/puppet/host_ldap_add_top.info.erb
index 7afdf2dd3ac2d9a629c31e77c695b6df8012bf7a..3aafc19438b2f2535d4ea83f420435008e9ebce5 100644 (file)
@@ -14,28 +14,3 @@ objectclass: ipHost
 environment: <%= @environment %>
 puppetVar: real_hostname=<%= @real_hostname %>
 userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
-EOF
-\e[0;35m#### Or modify an existing entry:\e[0m
-ldapmodify -D "cn=root,<%= @ldap_base %>" -W << 'EOF'
-dn: <%= @ldap_dn %>
-changetype: modify
-replace: userPassword
-userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
--
-replace: environment
-environment: <%= @environment %>
-<%- unless @ips.empty? -%>
--
-delete: ipHostNumber
-<%- unless @ips["v4"].nil? -%>
--
-add: ipHostNumber
-ipHostNumber: <%= @ips["v4"]["ipAddress"] %>
-<%- end -%>
-<%- unless @ips["v6"].nil? -%>
--
-add: ipHostNumber
-ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %>
-<%- end -%>
-<%- end -%>
-EOF
diff --git a/modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb b/modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb
new file mode 100644 (file)
index 0000000..d7a1294
--- /dev/null
@@ -0,0 +1,23 @@
+\e[0;35m#### Or modify an existing entry:\e[0m
+ldapmodify -D "cn=root,<%= @ldap_base %>" -W << 'EOF'
+dn: <%= @ldap_dn %>
+changetype: modify
+replace: userPassword
+userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
+-
+replace: environment
+environment: <%= @environment %>
+<%- unless @ips.empty? -%>
+-
+delete: ipHostNumber
+<%- unless @ips["v4"].nil? -%>
+-
+add: ipHostNumber
+ipHostNumber: <%= @ips["v4"]["ipAddress"] %>
+<%- end -%>
+<%- unless @ips["v6"].nil? -%>
+-
+add: ipHostNumber
+ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %>
+<%- end -%>
+<%- end -%>