win_stat - returns information about a Windows file
New in version 1.7.
Synopsis
- Returns information about a Windows file.
- For non-Windows targets, use the stat module instead.
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
checksum_algorithm (added in 2.3)
| no | sha1 |
| Algorithm to determine checksum of file. Will throw an error if the host is unable to use specified algorithm. |
get_checksum (added in 2.1)
| no | True | Whether to return a checksum of the file (default sha1) | |
get_md5 | no | True | Whether to return the checksum sum of the file. Between Ansible 1.9 and 2.2 this is no longer an MD5, but a SHA1 instead. As of Ansible 2.3 this is back to an MD5. Will return None if host is unable to use specified algorithm. This option is deprecated in Ansible 2.3 and is replaced with checksum_algorithm=md5 . | |
path | yes | The full path of the file/object to get the facts of; both forward and back slashes are accepted. |
Examples
- name: Obtain information about a file win_stat: path: C:\foo.ini register: file_info # Obtain information about a folder - win_stat: path: C:\bar register: folder_info # Get MD5 checksum of a file - win_stat: path: C:\foo.ini get_checksum: yes checksum_algorithm: md5 register: md5_checksum - debug: var: md5_checksum.stat.checksum # Get SHA1 checksum of file - win_stat: path: C:\foo.ini get_checksum: yes register: sha1_checksum - debug: var: sha1_checksum.stat.checksum # Get SHA256 checksum of file - win_stat: path: C:\foo.ini get_checksum: yes checksum_algorithm: sha256 register: sha256_checksum - debug: var: sha256_checksum.stat.checksum
Return Values
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
changed | Whether anything was changed | always | boolean | True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stat | dictionary containing all the stat data | success | complex | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
contains: |
|
Notes
Note
- For non-Windows targets, use the stat module instead.
Status
This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
Maintenance Info
For more information about Red Hat’s this support of this module, please refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/win_stat_module.html