query psql

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

Any feedback about my error?

Any feedback about my error?

The quotes are missing around vro03 when you execute it with Ansible.

BTW: Ansible 2.8. comes with a postgresql_query module.

Regards
         Racke