[Mageia-sysadm] [524] add a type postgres user, to be able to declare postgresql user in puppet directly

root at mageia.org root at mageia.org
Tue Dec 7 03:40:22 CET 2010


Revision: 524
Author:   misc
Date:     2010-12-07 03:40:22 +0100 (Tue, 07 Dec 2010)
Log Message:
-----------
add a type postgres user, to be able to declare postgresql user in puppet directly

Modified Paths:
--------------
    puppet/modules/postgresql/manifests/init.pp

Modified: puppet/modules/postgresql/manifests/init.pp
===================================================================
--- puppet/modules/postgresql/manifests/init.pp	2010-12-07 02:40:21 UTC (rev 523)
+++ puppet/modules/postgresql/manifests/init.pp	2010-12-07 02:40:22 UTC (rev 524)
@@ -67,4 +67,13 @@
         content => template("postgresql/pg_ident.conf"),
         require => Package["postgresql-server"],
     }
+
+    define user($password) {
+        $sql = "CREATE ROLE $name ENCRYPTED PASSWORD '$password' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;"
+
+        exec { "psql -U postgres -c \"$sql\" ":
+            user => root,
+            unless => "psql -A -t -U postgres -c '\du $name' | grep '$name'",
+        }
+    }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20101207/7c5ec8f0/attachment.html>


More information about the Mageia-sysadm mailing list