Dict to string; using json_query

In an Ansible playbook, I am using “with_file” to read a text file off the file system. It returns a dict.

  • name: show cvfr dictionary
    debug:
    msg: “{{item.key}}: {{item.value}}”
    loop: “{{ lookup(‘dict’, cos_vault_file) }}”

TASK [show cvfr dictionary] *********************************************************************************************************************************************************
ok: [localhost] => (item={‘key’: u’msg’, ‘value’: u’All items completed’}) => {
“msg”: “msg: All items completed”
}
ok: [localhost] => (item={‘key’: u’changed’, ‘value’: False}) => {
“msg”: “changed: False”
}
ok: [localhost] => (item={‘key’: u’results’, ‘value’: [{‘failed’: False, ‘ansible_loop_var’: u’item’, ‘changed’: False, u’item’: u’{\n “content”: "{\“request_id\”:\“d5c\"auth\\":null}\\n"\n}', ‘changed’: False}]”
}

When I try to use json_query to get the request_id, I get a null string.

set_fact:
requestid_cvfr: “{{cvfr_file.results | json_query(‘request_id’)}}”

After this, requestid_cvfr is “” where it should be “d5c”.

But I can print the results key :

  • name: show cvfr results
    debug:
    msg: “Results: {{cvfr_file.results}}”

TASK [show cvfr results] ************************************************************************************************************************************************************
ok: [localhost] => {
“msg”: “Results: [{‘failed’: False, ‘ansible_loop_var’: u’item’, ‘changed’: False, u’item’: u’{\n "content”: "{\“request_id\”:\“d5c\"auth\\":null}\\n"\n}', ‘changed’: False}]”
}

Please show me the command needed to retrieve the request_id from the cvfr_file.results. If I could use a string, I would get the correct response, but because it is a dict item, json_query is not able to retrieve the correct value.

Thanks in advance.