mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow dnf to remove dependent packages of a package that is being removed
Fixes #1517
This commit is contained in:
parent
78759c667a
commit
96f1bd82c0
1 changed files with 6 additions and 1 deletions
|
@ -241,6 +241,7 @@ def _mark_package_install(module, base, pkg_spec):
|
||||||
|
|
||||||
|
|
||||||
def ensure(module, base, state, names):
|
def ensure(module, base, state, names):
|
||||||
|
allow_erasing = False
|
||||||
if names == ['*'] and state == 'latest':
|
if names == ['*'] and state == 'latest':
|
||||||
base.upgrade_all()
|
base.upgrade_all()
|
||||||
else:
|
else:
|
||||||
|
@ -287,6 +288,7 @@ def ensure(module, base, state, names):
|
||||||
_mark_package_install(module, base, pkg_spec)
|
_mark_package_install(module, base, pkg_spec)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# state == absent
|
||||||
if filenames:
|
if filenames:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="Cannot remove paths -- please specify package name.")
|
msg="Cannot remove paths -- please specify package name.")
|
||||||
|
@ -298,8 +300,11 @@ def ensure(module, base, state, names):
|
||||||
for pkg_spec in pkg_specs:
|
for pkg_spec in pkg_specs:
|
||||||
if installed.filter(name=pkg_spec):
|
if installed.filter(name=pkg_spec):
|
||||||
base.remove(pkg_spec)
|
base.remove(pkg_spec)
|
||||||
|
# Like the dnf CLI we want to allow recursive removal of dependent
|
||||||
|
# packages
|
||||||
|
allow_erasing = True
|
||||||
|
|
||||||
if not base.resolve():
|
if not base.resolve(allow_erasing=allow_erasing):
|
||||||
module.exit_json(msg="Nothing to do")
|
module.exit_json(msg="Nothing to do")
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
|
Loading…
Add table
Reference in a new issue