diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:55:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:55:41 +0000 |
commit | 634758cfc77dff535c5e9e17cc99c6ba19e965b1 (patch) | |
tree | bb1c1a6bbff7abf9ed2d0e3b888480e70f0f109a /lib/ansible/modules/stat.py | |
parent | Adding upstream version 2.14.13. (diff) | |
download | ansible-core-634758cfc77dff535c5e9e17cc99c6ba19e965b1.tar.xz ansible-core-634758cfc77dff535c5e9e17cc99c6ba19e965b1.zip |
Adding upstream version 2.16.5.upstream/2.16.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/modules/stat.py')
-rw-r--r-- | lib/ansible/modules/stat.py | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/lib/ansible/modules/stat.py b/lib/ansible/modules/stat.py index 744ad8a..ee29251 100644 --- a/lib/ansible/modules/stat.py +++ b/lib/ansible/modules/stat.py @@ -36,7 +36,7 @@ options: description: - Algorithm to determine checksum of file. - Will throw an error if the host is unable to use specified algorithm. - - The remote host has to support the hashing method specified, C(md5) + - The remote host has to support the hashing method specified, V(md5) can be unavailable if the host is FIPS-140 compliant. type: str choices: [ md5, sha1, sha224, sha256, sha384, sha512 ] @@ -47,8 +47,8 @@ options: description: - Use file magic and return data about the nature of the file. this uses the 'file' utility found on most Linux/Unix systems. - - This will add both C(mimetype) and C(charset) fields to the return, if possible. - - In Ansible 2.3 this option changed from I(mime) to I(get_mime) and the default changed to C(true). + - This will add both RV(stat.mimetype) and RV(stat.charset) fields to the return, if possible. + - In Ansible 2.3 this option changed from O(mime) to O(get_mime) and the default changed to V(true). type: bool default: yes aliases: [ mime, mime_type, mime-type ] @@ -144,7 +144,7 @@ RETURN = r''' stat: description: Dictionary containing all the stat data, some platforms might add additional fields. returned: success - type: complex + type: dict contains: exists: description: If the destination path actually exists or not @@ -307,13 +307,6 @@ stat: type: str sample: ../foobar/21102015-1445431274-908472971 version_added: 2.4 - md5: - description: md5 hash of the file; this will be removed in Ansible 2.9 in - favor of the checksum return value - returned: success, path exists and user can read stats and path - supports hashing and md5 is supported - type: str - sample: f88fa92d8cf2eeecf4c0a50ccc96d0c0 checksum: description: hash of the file returned: success, path exists, user can read stats, path supports @@ -333,15 +326,15 @@ stat: mimetype: description: file magic data or mime-type returned: success, path exists and user can read stats and - installed python supports it and the I(get_mime) option was true, will - return C(unknown) on error. + installed python supports it and the O(get_mime) option was V(true), will + return V(unknown) on error. type: str sample: application/pdf; charset=binary charset: description: file character set or encoding returned: success, path exists and user can read stats and - installed python supports it and the I(get_mime) option was true, will - return C(unknown) on error. + installed python supports it and the O(get_mime) option was V(true), will + return V(unknown) on error. type: str sample: us-ascii readable: @@ -384,7 +377,7 @@ import stat # import module snippets from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils._text import to_bytes +from ansible.module_utils.common.text.converters import to_bytes def format_output(module, path, st): @@ -454,7 +447,6 @@ def main(): argument_spec=dict( path=dict(type='path', required=True, aliases=['dest', 'name']), follow=dict(type='bool', default=False), - get_md5=dict(type='bool', default=False), get_checksum=dict(type='bool', default=True), get_mime=dict(type='bool', default=True, aliases=['mime', 'mime_type', 'mime-type']), get_attributes=dict(type='bool', default=True, aliases=['attr', 'attributes']), @@ -473,10 +465,6 @@ def main(): get_checksum = module.params.get('get_checksum') checksum_algorithm = module.params.get('checksum_algorithm') - # NOTE: undocumented option since 2.9 to be removed at a later date if possible (3.0+) - # no real reason for keeping other than fear we may break older content. - get_md5 = module.params.get('get_md5') - # main stat data try: if follow: @@ -516,15 +504,6 @@ def main(): # checksums if output.get('isreg') and output.get('readable'): - - # NOTE: see above about get_md5 - if get_md5: - # Will fail on FIPS-140 compliant systems - try: - output['md5'] = module.md5(b_path) - except ValueError: - output['md5'] = None - if get_checksum: output['checksum'] = module.digest_from_file(b_path, checksum_algorithm) |