Skip to content

Commit

Permalink
zypper: support automatic removal of orphaned dependencies (#4195) (#…
Browse files Browse the repository at this point in the history
…4301)

* zypper: support automatic removal of orphaned dependencies

* zypper: support automatic removal of orphaned dependencies

  - Add support for --clean-deps option during package removal, which
    will clean up packages that were only installed as dependencies
    of the package being removed.

* Update changelogs/fragments/4192-zypper-add-clean-deps.yml

Co-authored-by: Felix Fontein <[email protected]>

* Update plugins/modules/packaging/os/zypper.py

Co-authored-by: Felix Fontein <[email protected]>

* Update plugins/modules/packaging/os/zypper.py

Co-authored-by: Felix Fontein <[email protected]>

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 9a34e97)

Co-authored-by: Jeff Mahoney <[email protected]>
  • Loading branch information
patchback[bot] and jeffmahoney authored Feb 28, 2022
1 parent 806ca0a commit deb95ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/4192-zypper-add-clean-deps.yml
Original file line number Diff line number Diff line change
@@ -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).
13 changes: 12 additions & 1 deletion plugins/modules/packaging/os/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
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.
Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit deb95ea

Please sign in to comment.