[__postgres_{database,role}] Run psql with --no-password (-w)

cdist does not work with interactive processes, so it's better to fail when
manual password input is required.
remotes/origin/cdist-5.0.0
Takashi Yoshi 6 years ago
parent aba1ae68f0
commit f7ace88ec2
  1. 2
      cdist/conf/type/__postgres_database/explorer/state
  2. 2
      cdist/conf/type/__postgres_role/explorer/state
  3. 2
      cdist/conf/type/__postgres_role/gencode-remote

@ -34,7 +34,7 @@ esac
name="$__object_id"
if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"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'
else

@ -34,7 +34,7 @@ esac
name="$__object_id"
if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")"
if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")"
then
echo 'present'
else

@ -55,7 +55,7 @@ case "$state_should" in
[ -n "$password" ] && password="PASSWORD '$password'"
cmd="CREATE ROLE $name WITH $password $booleans"
echo "su - '$postgres_user' -c \"psql postgres -c \\\"$cmd\\\"\""
echo "su - '$postgres_user' -c \"psql postgres -wc \\\"$cmd\\\"\""
;;
absent)
echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\""

Loading…
Cancel
Save