Fix discrepancy in behaviour between apt-get clean and its equivalent ansible.builtin.apt: clean=True (#82800)

* added integration test for issue 82611 regarding discrepency between apt-get clean and ansible.builtin.apt: clean

* fixed new line issue

* Implementation of bug fix for 82611

Fixed discrepancy in behaviour between apt-get clean and its equivalent ansible.builtin.apt: clean=True

Co-authored-by: Martin Krizek <martin.krizek@gmail.com>

---------

Co-authored-by: Martin Krizek <martin.krizek@gmail.com>
pull/82761/head
0x546f6d-W 2 months ago committed by GitHub
parent 936e757478
commit f02081b391
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- ansible.builtin.apt - calling clean = true does not properly clean certain cache files such as /var/cache/apt/pkgcache.bin and /var/cache/apt/pkgcache.bin (https://github.com/ansible/ansible/issues/82611)

@ -1315,7 +1315,7 @@ def main():
aptclean_stdout, aptclean_stderr, aptclean_diff = aptclean(module)
# If there is nothing else to do exit. This will set state as
# changed based on if the cache was updated.
if not p['package'] and not p['upgrade'] and not p['deb']:
if not p['package'] and p['upgrade'] == 'no' and not p['deb']:
module.exit_json(
changed=True,
msg=aptclean_stdout,

@ -594,3 +594,26 @@
- elpa-yaml-mode
state: absent
purge: yes
# https://github.com/ansible/ansible/issues/82611
- name: clean apt cache
apt:
clean: true
- name: check for /var/cache/apt/pkgcache.bin
stat:
path: /var/cache/apt/pkgcache.bin
register: pkgcache_bin
- name: check for /var/cache/apt/srcpkgcache.bin
stat:
path: /var/cache/apt/srcpkgcache.bin
register: srcpkgcache_bin
- name: verify apt cache files are cleaned
assert:
that:
- not pkgcache_bin.stat.exists
- not srcpkgcache_bin.stat.exists
fail_msg: "apt cache files still exist."
success_msg: "apt cache files are cleaned."

Loading…
Cancel
Save