remove deprecated get_md5 from stat (#55659)
* remove deprecated get_md5 from stat fixes #55309 * removed get_md5 from tests involving stat * keep get_md5 but hide it * rst it * ammended comment * ws * added ignore for hidden md5
This commit is contained in:
parent
cd95843ea5
commit
deae5b1bce
5 changed files with 10 additions and 53 deletions
2
changelogs/fragments/stat_no_md5.yml
Normal file
2
changelogs/fragments/stat_no_md5.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- removed previously deprecated ``get_md5`` option from M(stat) module.
|
|
@ -29,17 +29,6 @@ options:
|
|||
- Whether to follow symlinks.
|
||||
type: bool
|
||||
default: no
|
||||
get_md5:
|
||||
description:
|
||||
- Whether to return the md5 sum of the file.
|
||||
- Will return None if not a regular file or if we're
|
||||
unable to use md5 (Common for FIPS-140 compliant systems).
|
||||
- The default of this option changed from C(yes) to C(no) in Ansible 2.5
|
||||
and will be removed altogether in Ansible 2.9.
|
||||
- Use C(get_checksum=true) with C(checksum_algorithm=md5) to return an
|
||||
md5 hash under the C(checksum) return value.
|
||||
type: bool
|
||||
default: no
|
||||
get_checksum:
|
||||
description:
|
||||
- Whether to return a checksum of the file.
|
||||
|
@ -444,7 +433,7 @@ def main():
|
|||
argument_spec=dict(
|
||||
path=dict(type='path', required=True),
|
||||
follow=dict(type='bool', default=False),
|
||||
get_md5=dict(type='bool'),
|
||||
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']),
|
||||
|
@ -460,18 +449,13 @@ def main():
|
|||
follow = module.params.get('follow')
|
||||
get_mime = module.params.get('get_mime')
|
||||
get_attr = module.params.get('get_attributes')
|
||||
get_md5 = module.params.get('get_md5')
|
||||
|
||||
# get_md5 will be an undocumented option in 2.9 to be removed at a later
|
||||
# date if possible (3.0+)
|
||||
if get_md5:
|
||||
module.deprecate("get_md5 has been deprecated along with the md5 return value, use "
|
||||
"get_checksum=True and checksum_algorithm=md5 instead", 2.9)
|
||||
else:
|
||||
get_md5 = False
|
||||
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:
|
||||
|
@ -511,6 +495,8 @@ 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:
|
||||
|
|
|
@ -77,7 +77,6 @@
|
|||
- name: Check the stat results of the file
|
||||
stat:
|
||||
path: "{{ remote_file }}"
|
||||
get_md5: yes
|
||||
register: stat_results
|
||||
|
||||
- debug:
|
||||
|
@ -94,12 +93,6 @@
|
|||
- "stat_results.stat.issock == false"
|
||||
- "stat_results.stat.checksum == ('foo.txt\n'|hash('sha1'))"
|
||||
|
||||
- name: Verify that the legacy md5sum is correct
|
||||
assert:
|
||||
that:
|
||||
- "stat_results.stat.md5 == ('foo.txt\n'|hash('md5'))"
|
||||
when: ansible_fips|bool != True
|
||||
|
||||
- name: Overwrite the file via same means
|
||||
copy:
|
||||
src: foo.txt
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
- "'isreg' in stat_result.stat"
|
||||
- "'issock' in stat_result.stat"
|
||||
- "'isuid' in stat_result.stat"
|
||||
- "'md5' not in stat_result.stat" # Remove in 2.9
|
||||
- "'checksum' in stat_result.stat"
|
||||
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
|
||||
- "'mode' in stat_result.stat"
|
||||
|
@ -63,16 +62,6 @@
|
|||
- "'xoth' in stat_result.stat"
|
||||
- "'xusr' in stat_result.stat"
|
||||
|
||||
- name: check stat of file with get_md5
|
||||
stat: path={{output_dir}}/foo.txt get_md5=True
|
||||
register: stat_result_with_md5
|
||||
when: ansible_fips|bool != True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "stat_result_with_md5.stat.md5 == '5eb63bbbe01eeed093cb22bb8f5acdc3'"
|
||||
when: ansible_fips|bool != True
|
||||
|
||||
- name: make a symlink
|
||||
file:
|
||||
src: "{{ output_dir }}/foo.txt"
|
||||
|
@ -149,7 +138,6 @@
|
|||
- "'isreg' in stat_result.stat"
|
||||
- "'issock' in stat_result.stat"
|
||||
- "'isuid' in stat_result.stat"
|
||||
- "'md5' not in stat_result.stat"
|
||||
- "'checksum' in stat_result.stat"
|
||||
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
|
||||
- "'mode' in stat_result.stat"
|
||||
|
@ -167,16 +155,3 @@
|
|||
- "'xgrp' in stat_result.stat"
|
||||
- "'xoth' in stat_result.stat"
|
||||
- "'xusr' in stat_result.stat"
|
||||
|
||||
- name: check stat of a symlink with follow on with get_md5
|
||||
stat:
|
||||
path: "{{ output_dir }}/foo-link"
|
||||
follow: True
|
||||
get_md5: yes
|
||||
register: stat_result_with_md5
|
||||
when: ansible_fips|bool != True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "stat_result_with_md5.stat.md5 == '5eb63bbbe01eeed093cb22bb8f5acdc3'"
|
||||
when: ansible_fips|bool != True
|
||||
|
|
|
@ -354,6 +354,7 @@ lib/ansible/modules/files/lineinfile.py E323
|
|||
lib/ansible/modules/files/lineinfile.py E324
|
||||
lib/ansible/modules/files/lineinfile.py E326
|
||||
lib/ansible/modules/files/replace.py E323
|
||||
lib/ansible/modules/files/stat.py E322
|
||||
lib/ansible/modules/files/stat.py E336
|
||||
lib/ansible/modules/files/synchronize.py E322
|
||||
lib/ansible/modules/files/synchronize.py E323
|
||||
|
|
Loading…
Reference in a new issue