ansible / ansible.builtin / v2.3.3.0-1 / module / win_stat returns information about a Windows file | "added in version" 1.7 of ansible.builtin" Authors: Chris Church (@cchurch) stableinterface | supported by coreansible.builtin.win_stat (v2.3.3.0-1) — module
pip
Install with pip install ansible==2.3.3.0.post1
Returns information about a Windows file
- 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
path: description: - The full path of the file/object to get the facts of; both forward and back slashes are accepted. required: true get_md5: default: true description: - 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 C(checksum_algorithm=md5). required: false get_checksum: default: true description: - Whether to return a checksum of the file (default sha1) required: false version_added: '2.1' version_added_collection: ansible.builtin checksum_algorithm: choices: - md5 - sha1 - sha256 - sha384 - sha512 default: sha1 description: - Algorithm to determine checksum of file. Will throw an error if the host is unable to use specified algorithm. required: false version_added: '2.3' version_added_collection: ansible.builtin
changed: description: Whether anything was changed returned: always sample: true type: boolean stat: contains: attributes: description: attributes of the file at path in raw form returned: success, path exists sample: Archive, Hidden type: string checksum: description: The checksum of a file based on checksum_algorithm specified returned: success, path exist, path is a file, get_checksum == True checksum_algorithm specified is supported sample: 09cb79e8fc7453c84a07f644e441fd81623b7f98 type: string creationtime: description: the create time of the file represented in seconds since epoch returned: success, path exists sample: 1477984205.15 type: float exists: description: if the path exists or not returned: success sample: true type: boolean extension: description: the extension of the file at path returned: success, path exists, path is a file sample: .ps1 type: string filename: description: the name of the file (without path) returned: success, path exists, path is a file sammple: foo.ini type: string isarchive: description: if the path is ready for archiving or not returned: success, path exists sample: true type: boolean isdir: description: if the path is a directory or not returned: success, path exists sample: true type: boolean ishidden: description: if the path is hidden or not returned: success, path exists sample: true type: boolean islnk: description: if the path is a symbolic link or junction or not returned: success, path exists sample: true type: boolean isreadonly: description: if the path is read only or not returned: success, path exists sample: true type: boolean isshared: description: if the path is shared or not returned: success, path exists sample: true type: boolean lastaccesstime: description: the last access time of the file represented in seconds since epoch returned: success, path exists sample: 1477984205.15 type: float lastwritetime: description: the last modification time of the file represented in seconds since epoch returned: success, path exists sample: 1477984205.15 type: float lnk_source: description: the target of the symbolic link, will return null if not a link or the link is broken return: success, path exists, file is a symbolic link sample: C:\temp type: string md5: description: The MD5 checksum of a file (Between Ansible 1.9 and 2.2 this was returned as a SHA1 hash) returned: success, path exist, path is a file, get_md5 == True, md5 is supported sample: 09cb79e8fc7453c84a07f644e441fd81623b7f98 type: string owner: description: the owner of the file returned: success, path exists sample: BUILTIN\Administrators type: string path: description: the full absolute path to the file returned: success, path exists, file exists sample: C:\foo.ini type: string sharename: description: the name of share if folder is shared returned: success, path exists, file is a directory and isshared == True sample: file-share type: string size: description: the size in bytes of a file or folder returned: success, path exists, file is not a link sample: 1024 type: int description: dictionary containing all the stat data returned: success type: complex