diff --git a/changelogs/fragments/4192-zypper-add-clean-deps.yml b/changelogs/fragments/4192-zypper-add-clean-deps.yml new file mode 100644 index 0000000000..db436d7b77 --- /dev/null +++ b/changelogs/fragments/4192-zypper-add-clean-deps.yml @@ -0,0 +1,2 @@ +minor_changes: + - zypper - add support for ``--clean-deps`` option to remove packages that depend on a package being removed (https://github.com/ansible-collections/community.general/pull/4195). diff --git a/plugins/modules/packaging/os/zypper.py b/plugins/modules/packaging/os/zypper.py index 2295b5a566..43bba6404c 100644 --- a/plugins/modules/packaging/os/zypper.py +++ b/plugins/modules/packaging/os/zypper.py @@ -128,6 +128,13 @@ options: description: - Adds C(--replacefiles) option to I(zypper) install/update command. version_added: '0.2.0' + clean_deps: + type: bool + required: false + default: false + description: + - Adds C(--clean-deps) option to I(zypper) remove command. + version_added: '4.6.0' notes: - When used with a `loop:` each package will be processed individually, it is much more efficient to pass the list directly to the `name` option. @@ -368,6 +375,9 @@ def get_cmd(m, subcommand): cmd.append('--oldpackage') if m.params['replacefiles']: cmd.append('--replacefiles') + if subcommand == 'remove': + if m.params['clean_deps']: + cmd.append('--clean-deps') if subcommand == 'dist-upgrade' and m.params['allow_vendor_change']: cmd.append('--allow-vendor-change') if m.params['extra_args']: @@ -518,7 +528,8 @@ def main(): oldpackage=dict(required=False, default=False, type='bool'), extra_args=dict(required=False, default=None), allow_vendor_change=dict(required=False, default=False, type='bool'), - replacefiles=dict(required=False, default=False, type='bool') + replacefiles=dict(required=False, default=False, type='bool'), + clean_deps=dict(required=False, default=False, type='bool'), ), supports_check_mode=True )