aboutsummaryrefslogtreecommitdiffstats
path: root/modules/postgresql/manifests/user.pp
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2012-03-17 16:53:39 +0000
committerMichael Scherer <misc@mageia.org>2012-03-17 16:53:39 +0000
commit1baad5e9431cb5587482fd631f33fa36c64e9712 (patch)
tree9eeded6675c1587e4fd8c9785ce32f1677f6b65b /modules/postgresql/manifests/user.pp
parent568be2adf123420070be66dbcba4c9e8b8ef40c8 (diff)
downloadpuppet-1baad5e9431cb5587482fd631f33fa36c64e9712.tar
puppet-1baad5e9431cb5587482fd631f33fa36c64e9712.tar.gz
puppet-1baad5e9431cb5587482fd631f33fa36c64e9712.tar.bz2
puppet-1baad5e9431cb5587482fd631f33fa36c64e9712.tar.xz
puppet-1baad5e9431cb5587482fd631f33fa36c64e9712.zip
split postgresql::user in a separate file
Diffstat (limited to 'modules/postgresql/manifests/user.pp')
-rw-r--r--modules/postgresql/manifests/user.pp13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/postgresql/manifests/user.pp b/modules/postgresql/manifests/user.pp
new file mode 100644
index 00000000..b70dd122
--- /dev/null
+++ b/modules/postgresql/manifests/user.pp
@@ -0,0 +1,13 @@
+# TODO convert to a regular type, so we can later change password
+# without erasing the current user
+define postgresql::user($password) {
+ $sql = "CREATE ROLE $name ENCRYPTED PASSWORD '\$pass' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;"
+
+ exec { "psql -U postgres -c \"$sql\" ":
+ user => 'root',
+ # do not leak the password on commandline
+ environment => "pass=$password",
+ unless => "psql -A -t -U postgres -c '\\du $name' | grep '$name'",
+ require => Service['postgresql'],
+ }
+}