ansible.windows.win_find – Return a list of files based on specific criteria¶
Note
This plugin is part of the ansible.windows collection (version 1.5.0).
To install it use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_find
.
Synopsis¶
Return a list of files based on specified criteria.
Multiple criteria are AND’d together.
For non-Windows targets, use the ansible.builtin.find module instead.
Parameters¶
Examples¶
- name: Find files in path
ansible.windows.win_find:
paths: D:\Temp
- name: Find hidden files in path
ansible.windows.win_find:
paths: D:\Temp
hidden: yes
- name: Find files in multiple paths
ansible.windows.win_find:
paths:
- C:\Temp
- D:\Temp
- name: Find files in directory while searching recursively
ansible.windows.win_find:
paths: D:\Temp
recurse: yes
- name: Find files in directory while following symlinks
ansible.windows.win_find:
paths: D:\Temp
recurse: yes
follow: yes
- name: Find files with .log and .out extension using powershell wildcards
ansible.windows.win_find:
paths: D:\Temp
patterns: [ '*.log', '*.out' ]
- name: Find files in path based on regex pattern
ansible.windows.win_find:
paths: D:\Temp
patterns: out_\d{8}-\d{6}.log
- name: Find files older than 1 day
ansible.windows.win_find:
paths: D:\Temp
age: 86400
- name: Find files older than 1 day based on create time
ansible.windows.win_find:
paths: D:\Temp
age: 86400
age_stamp: ctime
- name: Find files older than 1 day with unit syntax
ansible.windows.win_find:
paths: D:\Temp
age: 1d
- name: Find files newer than 1 hour
ansible.windows.win_find:
paths: D:\Temp
age: -3600
- name: Find files newer than 1 hour with unit syntax
ansible.windows.win_find:
paths: D:\Temp
age: -1h
- name: Find files larger than 1MB
ansible.windows.win_find:
paths: D:\Temp
size: 1048576
- name: Find files larger than 1GB with unit syntax
ansible.windows.win_find:
paths: D:\Temp
size: 1g
- name: Find files smaller than 1MB
ansible.windows.win_find:
paths: D:\Temp
size: -1048576
- name: Find files smaller than 1GB with unit syntax
ansible.windows.win_find:
paths: D:\Temp
size: -1g
- name: Find folders/symlinks in multiple paths
ansible.windows.win_find:
paths:
- C:\Temp
- D:\Temp
file_type: directory
- name: Find files and return SHA256 checksum of files found
ansible.windows.win_find:
paths: C:\Temp
get_checksum: yes
checksum_algorithm: sha256
- name: Find files and do not return the checksum
ansible.windows.win_find:
paths: C:\Temp
get_checksum: no
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Jordan Borean (@jborean93)