I am using the win.find module along with the debug module to list files.
tasks:
- name: Find ALDM zip files
ansible.windows.win_find:
paths: c:\temp
recurse: no
patterns: “*.zip”
register: files_to_copy - debug:
msg: “{{files_to_copy}}”
This is what I get
“msg”: {
“changed”: false,
“examined”: 13,
“failed”: false,
“files”: [
{
“attributes”: “Archive”,
“checksum”: “2ac51252d04aa02addeda5a86270da2a925b13fc”,
“creationtime”: 1624860215.3043969,
“exists”: true,
“extension”: “.zip”,
“filename”: “xsapagos-xxstestwin-2106280603.zip”,
“hlnk_targets”: ,
“isarchive”: true,
“isdir”: false,
“ishidden”: false,
“isjunction”: false,
“islnk”: false,
“isreadonly”: false,
“isreg”: true,
“isshared”: false,
“lastaccesstime”: 1624860215.6950212,
“lastwritetime”: 1624860215.6950212,
“lnk_source”: null,
“lnk_target”: null,
“nlink”: 1,
“owner”: “BUILTIN\Administrators”,
“path”: "C:\temp\ xsapagos-xxstestwin-2106280603.zip ",
“sharename”: null,
“size”: 24556
},
How can I use debug to output just the filename
as I have tried the below
- debug:
msg: “{{files_to_copy.files.filename}}”
But I get → {“msg”: "The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘filename’\n\nThe error appears to be in