diff --git a/changelogs/fragments/stat_no_md5.yml b/changelogs/fragments/stat_no_md5.yml new file mode 100644 index 00000000000..f8ea16504e8 --- /dev/null +++ b/changelogs/fragments/stat_no_md5.yml @@ -0,0 +1,2 @@ +minor_changes: + - removed previously deprecated ``get_md5`` option from M(stat) module. diff --git a/lib/ansible/modules/files/stat.py b/lib/ansible/modules/files/stat.py index 6aa31108eb0..14ff90cb909 100644 --- a/lib/ansible/modules/files/stat.py +++ b/lib/ansible/modules/files/stat.py @@ -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: diff --git a/test/integration/targets/copy/tasks/tests.yml b/test/integration/targets/copy/tasks/tests.yml index fb6889e11e6..9d6edaf48e3 100644 --- a/test/integration/targets/copy/tasks/tests.yml +++ b/test/integration/targets/copy/tasks/tests.yml @@ -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 diff --git a/test/integration/targets/stat/tasks/main.yml b/test/integration/targets/stat/tasks/main.yml index 9cb551e6504..bd6b1e8960c 100644 --- a/test/integration/targets/stat/tasks/main.yml +++ b/test/integration/targets/stat/tasks/main.yml @@ -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 diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 6d4c831fd2c..14ac159d015 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -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