diff --git a/cdist/conf/type/__postgres_database/explorer/postgres_user b/cdist/conf/type/__postgres_database/explorer/postgres_user
new file mode 120000
index 00000000..714e7237
--- /dev/null
+++ b/cdist/conf/type/__postgres_database/explorer/postgres_user
@@ -0,0 +1 @@
+../../__postgres_conf/explorer/postgres_user
\ No newline at end of file
diff --git a/cdist/conf/type/__postgres_database/explorer/state b/cdist/conf/type/__postgres_database/explorer/state
index d68d4120..bb044e0e 100755
--- a/cdist/conf/type/__postgres_database/explorer/state
+++ b/cdist/conf/type/__postgres_database/explorer/state
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2021 Dennis Camera (dennis.camera at ssrq-sds-fds.ch)
#
# This file is part of cdist.
#
@@ -18,25 +19,13 @@
# along with cdist. If not, see .
#
-case "$("${__explorer}/os")"
-in
- netbsd)
- postgres_user='pgsql'
- ;;
- openbsd)
- postgres_user='_postgresql'
- ;;
- *)
- postgres_user='postgres'
- ;;
-esac
+postgres_user=$("${__type_explorer:?}/postgres_user")
+name=${__object_id:?}
-name="$__object_id"
-
-if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")"
+if test -n "$(su - "${postgres_user}" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='${name}'\"")"
then
- echo 'present'
+ echo 'present'
else
- echo 'absent'
+ echo 'absent'
fi
diff --git a/cdist/conf/type/__postgres_database/gencode-remote b/cdist/conf/type/__postgres_database/gencode-remote
index 0f11cff4..d70fc436 100755
--- a/cdist/conf/type/__postgres_database/gencode-remote
+++ b/cdist/conf/type/__postgres_database/gencode-remote
@@ -18,23 +18,12 @@
# along with cdist. If not, see .
#
-case "$(cat "${__global}/explorer/os")"
-in
- netbsd)
- postgres_user='pgsql'
- ;;
- openbsd)
- postgres_user='_postgresql'
- ;;
- *)
- postgres_user='postgres'
- ;;
-esac
name="$__object_id"
state_should="$(cat "$__object/parameter/state")"
state_is="$(cat "$__object/explorer/state")"
+postgres_user=$(cat "${__object:?}/explorer/postgres_user")
if [ "$state_should" != "$state_is" ]; then
case "$state_should" in