On Tue, 9 Aug 2022 05:09:41 -0700 (PDT)
"'Walter Rowe' via Ansible Project"
<[email protected]> wrote:

> You also can use json_query. 

For example, the template

shell> cat templates/server.xml.j2
insights.jdbc.password="{{ my_pswd }}"

and the task

    - debug:
        msg: "{{ lookup('template', 'server.xml.j2') }}"
      vars:
        my_user: user4
        my_pswd: "{{ postgres_create_users|
                     json_query(_query)|first }}"
        _query: '[?role==`{{ my_user }}`].password'

gives the same result

TASK [debug]
**************************************
ok: [localhost] => msg: |-
    insights.jdbc.password="password4"

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20220809150110.1f2bd3c9%40gmail.com.

Attachment: pgpG3mxmTxod9.pgp
Description: OpenPGP digital signature

Reply via email to