Any feedback about my error?


Le jeu. 16 mai 2019 à 16:47, Pierre Ochsenbein <[email protected]>
a écrit :

> Hi Guys
>
> I want to use a SQL query in PostgreSQL Database with ansible and a
> varibale which is call db_name.
> I have the result with my varibale.
> My problem is I don't know how interpret ' ' command in ansible with my
> variable
>
> My simple query works fine:
>
> -bash-4.2$ psql -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity
> WHERE datname = 'vro03';"
> pg_terminate_backend
> ----------------------
> t
> (1 row)
>
>
> Command line in my Playbook:
>   command: 'scl enable rh-postgresql10 "psql -Upostgres --command=\"SELECT
> pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename = {{ db_name
> }}\""'
>
>
> Output Error:
>
> TASK [../roles/removedb : Kill Session on Database]
> *****************************************************************************************************************************************
> fatal: [DEMO0249]: FAILED! => {"changed": false, "cmd": ["scl", "enable",
> "rh-postgresql10", "psql -Upostgres --command=\"SELECT
> pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename = vro03\""],
> "delta": "0:00:00.043902", "end": "2019-05-16 16:24:47.597238", "msg":
> "non-zero return code", "rc": 1, "start": "2019-05-16 16:24:47.553336",
> "stderr": "ERROR:  column \"vro03\" does not exist\nLINE 1:
> ...ate_backend(pid) FROM pg_stat_activity WHERE usename =
> vro03\n
> ^", "stderr_lines": ["ERROR:  column \"vro03\" does not exist", "LINE 1:
> ...ate_backend(pid) FROM pg_stat_activity WHERE usename = vro03",
> "                                                                  ^"],
> "stdout": "", "stdout_lines": []}
>         to retry, use: --limit
> @/home/ansible/projects/linuxbootstrap/playbooks/postgresql_removedb.retry
> PLAY RECAP
> **********************************************************************************************************************************************************************************
>
> DEMO0249                   : ok=1    changed=0    unreachable=0    failed=1
>


-- 
Cordialement,

*Pierre Ochsenbein*
Mobile: +33668295394
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CABG8FoN6Jz1FgNgN2aj5GsF0VJHzMCChXz1D_v-sxdAhva92dQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to