find module parse return value

Official documentation http://docs.ansible.com/ansible/find_module.html states, that main return value name is files and it’s “list of dictionaries”. Does anyone know how to parse this value? I’ve tried all possible loops, but I can’t figure out how to loop properly. I’ve read docs dozens of times, googled and nothing.

Basic code:

`

  • name: Get files
    find: paths=“/etc/” patterns=“*”
    register: find_results

  • name: Make sure line is present
    lineinfile: dest=/etc/cron.d/{{ item }} insertbefore=BOF line=“123”
    with_items: find_results.files
    `

This example doesn’t work, obviously, because as far as i understand, to traverse “list of dictionaries” you need to have with_dict inside with_items, but I don’t see a way to have nested loops of different types.

item would be a dictionary, I'm assuming what you want is a path:

lineinfile: dest={{ item.path }}

Thanks a lot for reply. You saved my day. I’ve been pulling my hair off for like 4 hours and the problem was simply in wrong “dest” value, because I didn’t see my mistake and treated error output not the way it should be :slight_smile:
with_items and item.path works of course