Hello,

It's inside a "results" list. The result of a loop?
In that case you need: {{ file_name.results[0].path }} to get the first
element of the "results" list.
If you have more, you need a loop to iterate it.

Nuno Jordão

On Mon, Mar 8, 2021 at 3:57 PM [email protected] <[email protected]>
wrote:

> How to extract a specific value from register output:
>
> From the below register output I’m trying to extract the * path *value
> with no luck, I have tried few options but still, I’m falling
>
>
> - debug:
>     msg: "{{ file_name }}" - debug:
>     msg: "{{ file_name.results.path }}"  - debug:
>     msg: "{{ file_name.path }}"
>
>
>
> File_name register output
>
>
>
>     "msg": {
>
>         "changed": false,
>
>         "msg": "All items completed",
>
>         "results": [
>
>             {
>
>                 "ansible_loop_var": "item",
>
>                 "changed": false,
>
>                 "checksum": "45823e35872e278fe781a182aa50abcd92d2df62",
>
>                 "dest": "/data/nifi-deployment/file_32.tar.gz",
>
>                 "diff": {
>
>                     "after": {
>
>                         "path": "/data/nifi-deployment/file_32.tar.gz"
>
>                     },
>
>                     "before": {
>
>                         "path": "/data/nifi-deployment/file_32.tar.gz"
>
>                     }
>
>                 },
>
>                 "failed": false,
>
>                 "gid": 0,
>
>                 "group": "root",
>
>                 "invocation": {
>
>                     "module_args": {
>
>                         "_diff_peek": null,
>
>                         "_original_basename": " file_32.tar.gz ",
>
>                         "access_time": null,
>
>                         "access_time_format": "%Y%m%d%H%M.%S",
>
>                         "attributes": null,
>
>                         "backup": null,
>
>                         "content": null,
>
>                         "delimiter": null,
>
>                         "dest": "/data/nifi-deployment",
>
>                         "directory_mode": null,
>
>                         "follow": true,
>
>                         "force": true,
>
>                         "group": null,
>
>                         "mode": null,
>
>                         "modification_time": null,
>
>                         "modification_time_format": "%Y%m%d%H%M.%S",
>
>                         "owner": null,
>
>                         "path": "/data/nifi-deployment/file_32.tar.gz",
>
>                         "recurse": false,
>
>                         "regexp": null,
>
>                         "remote_src": null,
>
>                         "selevel": null,
>
>                         "serole": null,
>
>                         "setype": null,
>
>                         "seuser": null,
>
>                         "src": null,
>
>                         "state": "file",
>
>                         "unsafe_writes": null
>
>                     }
>
>                 },
>
>                 "item": "/repo/file_32.tar.gz ",
>
>                 "mode": "0644",
>
>                 "owner": "root",
>
>               *  "path": "/data/nifi-deployment/file_32.tar.gz",*
>
>                 "secontext": "system_u:object_r:default_t:s0",
>
>                 "size": 4938,
>
>                 "state": "file",
>
>                 "uid": 0
>
>             }
>
>         ]
>
>     }
>
> }
>
> --
> 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/bdbb05c9-e58f-410d-8181-868ab76a5b11n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bdbb05c9-e58f-410d-8181-868ab76a5b11n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEAA%3Dtu6Z4H7zvDG5usE3-OpMQ19dW%2B%3DKRVPJ5M4Fya9wQBP%3Dw%40mail.gmail.com.

Reply via email to