Ansible : weirdness with jinja2_native=True

Viewed 35

I have to switch to jinja2_native=True, and some of my json_queries do not work anymore.

Playbook :

- name: Test JMESpath
  hosts: localhost
  gather_facts: no

  vars:
    name_to_find: "someName"
    name_to_find2: "someOtherName"
    type_to_find: "someType"


  tasks:
    - debug:
        msg: "query={{ query }}"
      vars:
        query: "[? (name == '{{ name_to_find }}' || name == '{{ name_to_find2 }}') && type == '{{ type_to_find }}' ]"

Output :

[bzjr2686@tower ansible-dev]$ ansible-playbook play-test_types.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Test JMESpath] **************************************************************************************************************************************************************************************************

TASK [debug] **********************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "query=[? (name == 'someName || name == someOtherName) && type == someType' ]"
}

PLAY RECAP ************************************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Output before jinja2_native :

[bzjr2686@tower ansible-dev]$ ansible-playbook play-test_types.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Test JMESpath] **************************************************************************************************************************************************************************************************

TASK [debug] **********************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "query=[? (name == 'someName' || name == 'someOtherName') && type == 'someType' ]"
}

PLAY RECAP ************************************************************************************************************************************************************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Where are the single quotes gone ?

1 Answers
Related