]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Merge branch 'dev'
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 5 Jun 2018 21:15:32 +0000 (23:15 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 5 Jun 2018 21:15:32 +0000 (23:15 +0200)
environments/global/roles/caldance.yaml [new file with mode: 0644]
modules/base_installation/lib/puppet/functions/ldap_data.rb
modules/base_installation/manifests/users.pp
modules/role/manifests/caldance.pp [new file with mode: 0644]

diff --git a/environments/global/roles/caldance.yaml b/environments/global/roles/caldance.yaml
new file mode 100644 (file)
index 0000000..1dc7fa8
--- /dev/null
@@ -0,0 +1,4 @@
+---
+classes:
+  role::caldance: ~
+letsencrypt::hosts: "%{lookup('base_installation::system_hostname')}"
index 0c92d8988dbf5cf047e21d25e395dc92c6d2efbb..0a6d9356af1b695b57dfefa5e0c2d4445d43a1eb 100644 (file)
@@ -30,9 +30,19 @@ Puppet::Functions.create_function(:ldap_data) do
       filter = "(objectclass=*)"
 
       data = {}
-      connection.search(base, scope, filter) do |entry|
-        data_ = entry.to_hash
-        jsons = data_["immaePuppetJson"] || []
+      data_array = connection.search2(base, scope, filter, attrs=["immaePuppetJson", "dn"]).map do |entry|
+        [entry["dn"].first, entry["immaePuppetJson"] || []]
+      end.sort_by do |dn, json|
+        if dn == "ou=roles,ou=hosts,dc=immae,dc=eu"
+          [0, dn]
+        elsif dn.end_with?("ou=roles,ou=hosts,dc=immae,dc=eu")
+          [1, dn]
+        else
+          [2, dn]
+        end
+      end.to_h
+
+      data_array.each do |dn, jsons|
         jsons.each do |json|
           data.merge!(JSON.parse(json))
         end
index 34df4bd08704beecd788df02741ec48f70314cb9..d0ac449a55a6a4c747212e9cd68f8637d80f0cec 100644 (file)
@@ -22,6 +22,13 @@ class base_installation::users (
 
   $users.each |$user| {
     if ($user["username"] != "root") {
+      unless $user["shell"] == undef or empty($user["shell"]) {
+        ensure_packages([$user["shell"]])
+        $shell = "/bin/${user[shell]}"
+      } else {
+        $shell = undef
+      }
+
       user { "${user[username]}:${user[userid]}":
         name           => $user[username],
         uid            => $user[userid],
@@ -30,6 +37,7 @@ class base_installation::users (
         managehome     => true,
         system         => !!$user[system],
         home           => "/home/${user[username]}",
+        shell          => $shell,
         notify         => Exec["remove_password:${user[username]}:${user[userid]}"],
         purge_ssh_keys => true
       }
diff --git a/modules/role/manifests/caldance.pp b/modules/role/manifests/caldance.pp
new file mode 100644 (file)
index 0000000..75d9dbd
--- /dev/null
@@ -0,0 +1,11 @@
+class role::caldance (
+) {
+  include "base_installation"
+
+  include "profile::tools"
+  include "profile::postgresql"
+  include "profile::apache"
+  include "profile::redis"
+
+  ensure_packages(["python-pip", "python-virtualenv", "python-django"])
+}