Debian Codegraph @

test/support/windows-integration/plugins/modules/win_stat.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2017, Ansible Project
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 # this is a windows documentation stub. actual code lives in the .ps1
8 # file of the same name
9
10 ANSIBLE_METADATA = {'metadata_version': '1.1',
11 'status': ['stableinterface'],
12 'supported_by': 'core'}
13
14 DOCUMENTATION = r"""
15 ---
16 module: win_stat
17 version_added: "1.7"
18 short_description: Get information about Windows files
19 description:
20 - Returns information about a Windows file.
21 - For non-Windows targets, use the M(stat) module instead.
22 options:
23 path:
24 description:
25 - The full path of the file/object to get the facts of; both forward and
26 back slashes are accepted.
27 type: path
28 required: yes
29 aliases: [ dest, name ]
30 get_checksum:
31 description:
32 - Whether to return a checksum of the file (default sha1)
33 type: bool
34 default: yes
35 version_added: "2.1"
36 checksum_algorithm:
37 description:
38 - Algorithm to determine checksum of file.
39 - Will throw an error if the host is unable to use specified algorithm.
40 type: str
41 default: sha1
42 choices: [ md5, sha1, sha256, sha384, sha512 ]
43 version_added: "2.3"
44 follow:
45 description:
46 - Whether to follow symlinks or junction points.
47 - In the case of C(path) pointing to another link, then that will
48 be followed until no more links are found.
49 type: bool
50 default: no
51 version_added: "2.8"
52 seealso:
53 - module: stat
54 - module: win_acl
55 - module: win_file
56 - module: win_owner
57 author:
58 - Chris Church (@cchurch)
59 """
60
61 EXAMPLES = r"""
62 - name: Obtain information about a file
63 win_stat:
64 path: C:\foo.ini
65 register: file_info
66
67 - name: Obtain information about a folder
68 win_stat:
69 path: C:\bar
70 register: folder_info
71
72 - name: Get MD5 checksum of a file
73 win_stat:
74 path: C:\foo.ini
75 get_checksum: yes
76 checksum_algorithm: md5
77 register: md5_checksum
78
79 - debug:
80 var: md5_checksum.stat.checksum
81
82 - name: Get SHA1 checksum of file
83 win_stat:
84 path: C:\foo.ini
85 get_checksum: yes
86 register: sha1_checksum
87
88 - debug:
89 var: sha1_checksum.stat.checksum
90
91 - name: Get SHA256 checksum of file
92 win_stat:
93 path: C:\foo.ini
94 get_checksum: yes
95 checksum_algorithm: sha256
96 register: sha256_checksum
97
98 - debug:
99 var: sha256_checksum.stat.checksum
100 """
101
102 RETURN = r"""
103 changed:
104 description: Whether anything was changed
105 returned: always
106 type: bool
107 sample: true
108 stat:
109 description: dictionary containing all the stat data
110 returned: success
111 type: complex
112 contains:
113 attributes:
114 description: Attributes of the file at path in raw form.
115 returned: success, path exists
116 type: str
117 sample: "Archive, Hidden"
118 checksum:
119 description: The checksum of a file based on checksum_algorithm specified.
120 returned: success, path exist, path is a file, get_checksum == True
121 checksum_algorithm specified is supported
122 type: str
123 sample: 09cb79e8fc7453c84a07f644e441fd81623b7f98
124 creationtime:
125 description: The create time of the file represented in seconds since epoch.
126 returned: success, path exists
127 type: float
128 sample: 1477984205.15
129 exists:
130 description: If the path exists or not.
131 returned: success
132 type: bool
133 sample: true
134 extension:
135 description: The extension of the file at path.
136 returned: success, path exists, path is a file
137 type: str
138 sample: ".ps1"
139 filename:
140 description: The name of the file (without path).
141 returned: success, path exists, path is a file
142 type: str
143 sample: foo.ini
144 hlnk_targets:
145 description: List of other files pointing to the same file (hard links), excludes the current file.
146 returned: success, path exists
147 type: list
148 sample:
149 - C:\temp\file.txt
150 - C:\Windows\update.log
151 isarchive:
152 description: If the path is ready for archiving or not.
153 returned: success, path exists
154 type: bool
155 sample: true
156 isdir:
157 description: If the path is a directory or not.
158 returned: success, path exists
159 type: bool
160 sample: true
161 ishidden:
162 description: If the path is hidden or not.
163 returned: success, path exists
164 type: bool
165 sample: true
166 isjunction:
167 description: If the path is a junction point or not.
168 returned: success, path exists
169 type: bool
170 sample: true
171 islnk:
172 description: If the path is a symbolic link or not.
173 returned: success, path exists
174 type: bool
175 sample: true
176 isreadonly:
177 description: If the path is read only or not.
178 returned: success, path exists
179 type: bool
180 sample: true
181 isreg:
182 description: If the path is a regular file.
183 returned: success, path exists
184 type: bool
185 sample: true
186 isshared:
187 description: If the path is shared or not.
188 returned: success, path exists
189 type: bool
190 sample: true
191 lastaccesstime:
192 description: The last access time of the file represented in seconds since epoch.
193 returned: success, path exists
194 type: float
195 sample: 1477984205.15
196 lastwritetime:
197 description: The last modification time of the file represented in seconds since epoch.
198 returned: success, path exists
199 type: float
200 sample: 1477984205.15
201 lnk_source:
202 description: Target of the symlink normalized for the remote filesystem.
203 returned: success, path exists and the path is a symbolic link or junction point
204 type: str
205 sample: C:\temp\link
206 lnk_target:
207 description: Target of the symlink. Note that relative paths remain relative.
208 returned: success, path exists and the path is a symbolic link or junction point
209 type: str
210 sample: ..\link
211 nlink:
212 description: Number of links to the file (hard links).
213 returned: success, path exists
214 type: int
215 sample: 1
216 owner:
217 description: The owner of the file.
218 returned: success, path exists
219 type: str
220 sample: BUILTIN\Administrators
221 path:
222 description: The full absolute path to the file.
223 returned: success, path exists, file exists
224 type: str
225 sample: C:\foo.ini
226 sharename:
227 description: The name of share if folder is shared.
228 returned: success, path exists, file is a directory and isshared == True
229 type: str
230 sample: file-share
231 size:
232 description: The size in bytes of a file or folder.
233 returned: success, path exists, file is not a link
234 type: int
235 sample: 1024
236 """