1

I want to target the path variable in this output of Ansible.

ok: [myMachine1] => { "foundFiles": { ... "results": [ { ... "files": [ { ... "path": "/my/first/path", ... } ], }, { ... "files": [ { ... "path": "/my/second/path", ... } } ] } } 

How can I tell Ansible to target the 'path' variables. I'm trying with:

 - debug: msg: "{{ item.files.path }}" with_items: - foundFiles.results 

But only getting "failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'key'

Thanks guru's.

1 Answer 1

2

First: bare variables are not supported since Ansible 2.2
Second: files is a list in your example

- debug: msg="{{ item.files[0].path }}" with_items: "{{ foundFiles.results }}" 

If you have multiple entries under in files list, you should consider to map it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.