diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index a3280c09..c9de4707 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -22,33 +22,28 @@ name="$__object_id" state_is="$(cat "$__object/explorer/state")" state_should="$(cat "$__object/parameter/state")" -if [ "$state_is" != "$state_should" ]; then - case "$state_should" in - present) - optional="password - login - createdb - createrole - superuser" - for parameter in $optional; do - if [ -f "$__object/parameter/$parameter" ]; then - value="$(cat "$__object/parameter/$parameter")" - eval $parameter=$value +[ "$state_is" = "$state_should" ] && exit 0 + +case "$state_should" in + present) + if [ -f "$__object/parameter/password" ]; then + password="$(cat "$__object/parameter/$parameter")" + fi + booleans="" + for boolean in login createdb createrole superuser; do + if [ ! -f "$__object/parameter/$boolean" ]; then + boolean="no${boolean}" fi - done + upper=$(echo $boolean | tr '[a-z]' '[A-Z]') + booleans="$booleans $upper" + done [ -n "$password" ] && password="PASSWORD '$password'" - [ "$login" = "true" ] && login="LOGIN" || login="NOLOGIN" - [ "$createdb" = "true" ] && createdb="CREATEDB" || createdb="NOCREATEDB" - [ "$createrole" = "true" ] && createrole="CREATEROLE" || createrole="NOCREATEROLE" - [ "$superuser" = "true" ] && superuser="SUPERUSER" || superuser="NOSUPERUSER" - [ "$inherit" = "true" ] && inherit="INHERIT" || inherit="NOINHERIT" - cmd="CREATE ROLE $name WITH $password $login $createdb $createrole $superuser $inherit" + cmd="CREATE ROLE $name WITH $password $booleans" echo "su - postgres -c \"psql -c \\\"$cmd\\\"\"" - ;; - absent) - echo "su - postgres -c \"dropuser \\\"$name\\\"\"" - ;; - esac -fi + ;; + absent) + echo "su - postgres -c \"dropuser \\\"$name\\\"\"" + ;; +esac diff --git a/cdist/conf/type/__postgres_role/man.text b/cdist/conf/type/__postgres_role/man.text index 9b917060..4f13fa53 100644 --- a/cdist/conf/type/__postgres_role/man.text +++ b/cdist/conf/type/__postgres_role/man.text @@ -21,17 +21,22 @@ state:: OPTIONAL PARAMETERS ------------------- -All optional parameter map directly to the corresponding postgres createrole +All parameter map directly to the corresponding postgres createrole parameters. password:: + +BOOLEAN PARAMETERS +------------------ +All parameter map directly to the corresponding postgres createrole +parameters. + login:: createdb:: createrole:: superuser:: inherit:: - EXAMPLES -------- @@ -40,9 +45,9 @@ __postgres_role myrole --state present __postgres_role myrole --state present --password 'secret' -__postgres_role admin --state present --password 'very-secret' --superuser true +__postgres_role admin --state present --password 'very-secret' --superuser -__postgres_role dbcustomer --state present --password 'bla' --createdb true +__postgres_role dbcustomer --state present --password 'bla' --createdb -------------------------------------------------------------------------------- diff --git a/cdist/conf/type/__postgres_role/parameter/boolean b/cdist/conf/type/__postgres_role/parameter/boolean new file mode 100644 index 00000000..a581b3fd --- /dev/null +++ b/cdist/conf/type/__postgres_role/parameter/boolean @@ -0,0 +1,5 @@ +login +createdb +createrole +superuser +inherit diff --git a/cdist/conf/type/__postgres_role/parameter/optional b/cdist/conf/type/__postgres_role/parameter/optional index c5abb57f..f3097ab1 100644 --- a/cdist/conf/type/__postgres_role/parameter/optional +++ b/cdist/conf/type/__postgres_role/parameter/optional @@ -1,6 +1 @@ password -login -createdb -createrole -superuser -inherit diff --git a/docs/changelog b/docs/changelog index b91b01c7..56750722 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,10 @@ Changelog * Bugfix Type __rvm_ruby: Add clean package dependencies * Bugfix Type __rvm_gem: Run rvm as user, not as root * Cleanup Type __rvm, __rvm_gemset: Use shortcut version + * Bugfix __rvm_gemset: Correctly check for gemsets + * Cleanup Type __postgres_database, __postgres_role: Reference each other + in documentation + * Cleanp Type __postgres_role: Use boolean parameters where appropriate 2.1.0pre5: 2012-11-01 * Core: First round of tests updated to work with multiple configuration directories