database - Run a postgresql command with ansible playbook. Postgresql requires password -
i write ansible playbook tries handle postgresql command. did earlier similar playbook, in case postgresql didn't need password.
i thought use old playbook, works fine, wrong. database requires password. know ansible has postgresql support fine (postgresql_db, postgresql_ext, postgresql_lang, postgresql_privs, postgresql_user) , them can half of work , handles password fine, can't figure out how send simple sql commands database. in old playbook used "shell" command send requests (eg: shell: "psql {{ databases.name }} --username {{ admin_user}} -c 'drop schema public cascade;'"
).
and upload db_dump. earlier used psql this, new database requires password...
can give me tips how handle situation? i'm using ansible 2.0 , database can reached specific remote host.
thanks
create .pgpass
file @ non-default location part of playbook, , put password there. specify location in pgpassfile
environment variable. delete once it's no longer needed.
see libpq environment variables.
alternately think can use connection string connect , specify password part of connection string, e.g.
'dbname=mydb user=fred password=borkbork'
(untested)
Comments
Post a Comment