I am trying to process a list of subfolders, but am having trouble 
dereferencing the data
If I run the following playbook

---
- name: Get folders under c:\Users
  hosts: ychtrn1d
  gather_facts: false
  tasks:
    - name: Determine which folders exist under Users
      win_find:
        paths: 'c:\Users\'
        file_type: directory
      register: folders
    - debug:
         msg: "{{ folders }}"

I get this (some data removed for brevity)

ok: [ychtrn1d] => {
    "msg": {
        "changed": false,
        "failed": false,
        "files": [
            {
                "creationtime": 1415372291.3851476,
                "filename": "administrator",
                "size": 3009061740
            },
            {
                "creationtime": 1247523608.929812,
                "filename": "Public",
                "size": 120599529
            },
            {
                "creationtime": 1415371442.8504908,
                "filename": "test",
                "size": 70521
            }
        ],
        "matched": 3
    }
}

I want to loop through the 3 filename values, so I change playlist to

---
- name: Get folders under c:\Users
  hosts: ychtrn1d
  gather_facts: false
  tasks:
    - name: Determine which folders exist under Users
      win_find:
        paths: 'c:\Users\'
        file_type: directory
      register: folders
    - debug:
         msg: "{{ item }}"
      loop: "{{ folders.files.filename }}"

This fails

fatal: [ychtrn1d]: FAILED! => {"msg": "'list object' has no attribute 
'filename'"}

However, changing to 

      loop: "{{ folders.files }}"

does return data, just more than I need

I am familiar with perl arrays/hashes but not in ansible/yaml

How can I return only "filename" data?



         

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/41c546e3-03f6-4fd9-ba5a-766721447116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to