Get information about Windows files
- Returns information about a Windows file.
- For non-Windows targets, use the :ref:`ansible.builtin.stat <ansible.builtin.stat_module>` module instead.
.. seealso:: :ref:`ansible.builtin.stat_module` The official documentation on the **ansible.builtin.stat** module. :ref:`ansible.windows.win_acl_module` The official documentation on the **ansible.windows.win_acl** module. :ref:`ansible.windows.win_file_module` The official documentation on the **ansible.windows.win_file** module. :ref:`ansible.windows.win_owner_module` The official documentation on the **ansible.windows.win_owner** module.
- name: Obtain information about a file
ansible.windows.win_stat:
path: C:\foo.ini
register: file_info
- name: Obtain information about a folder
ansible.windows.win_stat:
path: C:\bar
register: folder_info
- name: Get MD5 checksum of a file
ansible.windows.win_stat:
path: C:\foo.ini
get_checksum: yes
checksum_algorithm: md5
register: md5_checksum
- debug:
var: md5_checksum.stat.checksum
- name: Get SHA1 checksum of file
ansible.windows.win_stat:
path: C:\foo.ini
get_checksum: yes
register: sha1_checksum
- debug:
var: sha1_checksum.stat.checksum
- name: Get SHA256 checksum of file
ansible.windows.win_stat:
path: C:\foo.ini
get_checksum: yes
checksum_algorithm: sha256
register: sha256_checksum
- debug:
var: sha256_checksum.stat.checksum
Common return values are documented here, the following are the fields unique to this module:
- Chris Church (@cchurch)