From 7dc85dc776e158e26202362f11a72d7491ef07c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 14 Aug 2018 22:49:29 +0200 Subject: Change host_ldap to concat --- modules/base_installation/manifests/puppet.pp | 32 ++++++++++++++--- .../templates/puppet/host_ldap.info.erb | 41 ---------------------- .../templates/puppet/host_ldap_add_top.info.erb | 16 +++++++++ .../templates/puppet/host_ldap_mod_top.info.erb | 23 ++++++++++++ 4 files changed, 67 insertions(+), 45 deletions(-) delete mode 100644 modules/base_installation/templates/puppet/host_ldap.info.erb create mode 100644 modules/base_installation/templates/puppet/host_ldap_add_top.info.erb create mode 100644 modules/base_installation/templates/puppet/host_ldap_mod_top.info.erb (limited to 'modules') 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 ( } $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": diff --git a/modules/base_installation/templates/puppet/host_ldap.info.erb b/modules/base_installation/templates/puppet/host_ldap.info.erb deleted file mode 100644 index 7afdf2d..0000000 --- a/modules/base_installation/templates/puppet/host_ldap.info.erb +++ /dev/null @@ -1,41 +0,0 @@ -#### Please add this node to LDAP: -ldapadd -D "cn=root,<%= @ldap_base %>" -W << 'EOF' -dn: <%= @ldap_dn %> -cn: <%= @ldap_cn %> -objectclass: device -objectclass: top -objectclass: simpleSecurityObject -objectclass: puppetClient -<%- unless @ips.empty? -%> -objectclass: ipHost -<% unless @ips["v4"].nil? -%>ipHostNumber: <%= @ips["v4"]["ipAddress"] %><%- end %> -<% unless @ips["v6"].nil? -%>ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %><%- end %> -<%- end -%> -environment: <%= @environment %> -puppetVar: real_hostname=<%= @real_hostname %> -userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %> -EOF -#### Or modify an existing entry: -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_add_top.info.erb b/modules/base_installation/templates/puppet/host_ldap_add_top.info.erb new file mode 100644 index 0000000..3aafc19 --- /dev/null +++ b/modules/base_installation/templates/puppet/host_ldap_add_top.info.erb @@ -0,0 +1,16 @@ +#### Please add this node to LDAP: +ldapadd -D "cn=root,<%= @ldap_base %>" -W << 'EOF' +dn: <%= @ldap_dn %> +cn: <%= @ldap_cn %> +objectclass: device +objectclass: top +objectclass: simpleSecurityObject +objectclass: puppetClient +<%- unless @ips.empty? -%> +objectclass: ipHost +<% unless @ips["v4"].nil? -%>ipHostNumber: <%= @ips["v4"]["ipAddress"] %><%- end %> +<% unless @ips["v6"].nil? -%>ipHostNumber: <%= @ips["v6"]["ipAddress"] %>/<%= @ips["v6"]["mask"] %><%- end %> +<%- end -%> +environment: <%= @environment %> +puppetVar: real_hostname=<%= @real_hostname %> +userpassword: {SSHA}<%= Base64.encode64(Digest::SHA1.digest(@ldap_password+@ssha_ldap_seed)+@ssha_ldap_seed).chomp! %> 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 @@ +#### Or modify an existing entry: +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 -%> -- cgit v1.2.3