title: How to get postgresql_query results from Ansible
body: <p>I'm trying to print the output of PostgreSQL query that is run by Ansible.  Unfortunately I'm not sure how to get ahold of the return value.</p>
  
  <pre><code>    - name: Get specific tables
        postgresql_query:
          db: "{{ database_name }}"
          login_host: "{{ my_host }}"
          login_user: "{{ my_user }}"
          login_password: "{{ my_password }}"
          query: SELECT * FROM pg_tables t WHERE t.tableowner = current_user
  </code></pre>
  
  <p>Googling just says to use <code>register:</code>, but the PostgreSQL ansible module does not have a <code>register</code> param:</p>
  
  <pre><code>fatal: [xx.xxx.xx.xx]: FAILED! =&gt; {"changed": false, "msg": "Unsupported parameters for (postgresql_query) module: register Supported parameters include: ca_cert, db, login_host, login_password, login_unix_socket, login_user, named_args, path_to_script, port, positional_args, query, session_role, ssl_mode"}
  </code></pre>
  
  <p>The <a href="https://docs.ansible.com/ansible/latest/modules/postgresql_query_module.html#return-values" rel="nofollow noreferrer">Ansible docs</a> list return values for this module but there are no examples on how to use them, and everything I search for <a href="https://stackoverflow.com/a/29374522/3316036">leads right back to <code>register:</code></a>.</p>