aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-08-14 22:49:29 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-08-17 12:50:25 +0200
commit7dc85dc776e158e26202362f11a72d7491ef07c8 (patch)
treea3e1c6d358efe68d8f00604ae10377735aca76cb
parent7f8c632757246813c0a9fdbf0c26ef036ff396be (diff)
downloadPuppet-7dc85dc776e158e26202362f11a72d7491ef07c8.tar.gz
Puppet-7dc85dc776e158e26202362f11a72d7491ef07c8.tar.zst
Puppet-7dc85dc776e158e26202362f11a72d7491ef07c8.zip
Change host_ldap to concat
-rw-r--r--modules/base_installation/manifests/puppet.pp32
-rw-r--r--modules/base_installation/templates/puppet/host_ldap_add_top.info.erb (renamed from modules/base_installation/templates/puppet/host_ldap.info.erb)25
-rw-r--r--modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb23
3 files changed, 51 insertions, 29 deletions
diff --git a/modules/base_installation/manifests/puppet.pp b/modules/base_installation/manifests/puppet.pp
index 05fe9a1..10b3773 100644
--- a/modules/base_installation/manifests/puppet.pp
+++ b/modules/base_installation/manifests/puppet.pp
@@ -109,10 +109,34 @@ class base_installation::puppet (
109 } 109 }
110 110
111 $ips = lookup("ips", { 'default_value' => undef }) 111 $ips = lookup("ips", { 'default_value' => undef })
112 file { "$base_installation::puppet_conf_path/host_ldap.info": 112 concat { "$base_installation::puppet_conf_path/host_ldap.info":
113 content => template("base_installation/puppet/host_ldap.info.erb"), 113 ensure => "present",
114 require => File[$base_installation::puppet_conf_path], 114 mode => "0600",
115 notify => Notify_refresh["notify-ldap-password"], 115 require => File[$base_installation::puppet_conf_path],
116 notify => Notify_refresh["notify-ldap-password"],
117 ensure_newline => true,
118 }
119
120 concat::fragment { "host_ldap add top":
121 target => "$base_installation::puppet_conf_path/host_ldap.info",
122 content => template("base_installation/puppet/host_ldap_add_top.info.erb"),
123 order => "00-01",
124 }
125 concat::fragment { "host_ldap add bottom":
126 target => "$base_installation::puppet_conf_path/host_ldap.info",
127 content => "EOF",
128 order => "00-99",
129 }
130
131 concat::fragment { "host_ldap mod top":
132 target => "$base_installation::puppet_conf_path/host_ldap.info",
133 content => template("base_installation/puppet/host_ldap_mod_top.info.erb"),
134 order => "01-01",
135 }
136 concat::fragment { "host_ldap mod bottom":
137 target => "$base_installation::puppet_conf_path/host_ldap.info",
138 content => "EOF",
139 order => "01-99",
116 } 140 }
117 141
118 notify_refresh { "notify-ldap-password": 142 notify_refresh { "notify-ldap-password":
diff --git a/modules/base_installation/templates/puppet/host_ldap.info.erb b/modules/base_installation/templates/puppet/host_ldap_add_top.info.erb
index 7afdf2d..3aafc19 100644
--- a/modules/base_installation/templates/puppet/host_ldap.info.erb
+++ b/modules/base_installation/templates/puppet/host_ldap_add_top.info.erb
@@ -14,28 +14,3 @@ objectclass: ipHost
14environment: <%= @environment %> 14environment: <%= @environment %>
15puppetVar: real_hostname=<%= @real_hostname %> 15puppetVar: real_hostname=<%= @real_hostname %>
16userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %> 16userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
17EOF
18#### Or modify an existing entry:
19ldapmodify -D "cn=root,<%= @ldap_base %>" -W << 'EOF'
20dn: <%= @ldap_dn %>
21changetype: modify
22replace: userPassword
23userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
24-
25replace: environment
26environment: <%= @environment %>
27<%- unless @ips.empty? -%>
28-
29delete: ipHostNumber
30<%- unless @ips["v4"].nil? -%>
31-
32add: ipHostNumber
33ipHostNumber: <%= @ips["v4"]["ipAddress"] %>
34<%- end -%>
35<%- unless @ips["v6"].nil? -%>
36-
37add: ipHostNumber
38ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %>
39<%- end -%>
40<%- end -%>
41EOF
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
index 0000000..d7a1294
--- /dev/null
+++ b/modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb
@@ -0,0 +1,23 @@
1#### Or modify an existing entry:
2ldapmodify -D "cn=root,<%= @ldap_base %>" -W << 'EOF'
3dn: <%= @ldap_dn %>
4changetype: modify
5replace: userPassword
6userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %>
7-
8replace: environment
9environment: <%= @environment %>
10<%- unless @ips.empty? -%>
11-
12delete: ipHostNumber
13<%- unless @ips["v4"].nil? -%>
14-
15add: ipHostNumber
16ipHostNumber: <%= @ips["v4"]["ipAddress"] %>
17<%- end -%>
18<%- unless @ips["v6"].nil? -%>
19-
20add: ipHostNumber
21ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %>
22<%- end -%>
23<%- end -%>