Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zypper: add additional flag force_resolution #61705

Merged
merged 1 commit into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/ansible/modules/packaging/os/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
required: false
default: "no"
type: bool
force_resolution:
version_added: "2.10"
description:
- Adds C(--force-resolution) option to I(zypper). Allows to (un)install packages with conflicting requirements (resolver will choose a solution).
required: false
default: "no"
type: bool
update_cache:
version_added: "2.2"
description:
Expand Down Expand Up @@ -338,6 +345,8 @@ def get_cmd(m, subcommand):
cmd.append('--no-recommends')
if m.params['force']:
cmd.append('--force')
if m.params['force_resolution']:
cmd.append('--force-resolution')
if m.params['oldpackage']:
cmd.append('--oldpackage')
if m.params['extra_args']:
Expand Down Expand Up @@ -479,6 +488,7 @@ def main():
disable_gpg_check=dict(required=False, default='no', type='bool'),
disable_recommends=dict(required=False, default='yes', type='bool'),
force=dict(required=False, default='no', type='bool'),
force_resolution=dict(required=False, default='no', type='bool'),
update_cache=dict(required=False, aliases=['refresh'], default='no', type='bool'),
oldpackage=dict(required=False, default='no', type='bool'),
extra_args=dict(required=False, default=None),
Expand Down
24 changes: 24 additions & 0 deletions test/integration/targets/zypper/tasks/zypper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,27 @@
- zypper_result_update_cache is successful
- zypper_result_update_cache_check is successful
- zypper_result_update_cache_check is not changed


- name: install netcat-openbsd which conflicts with gnu-netcat
zypper:
name: netcat-openbsd
state: present

- name: try installation of gnu-netcat which should fail due to the conflict
zypper:
name: gnu-netcat
state: present
ignore_errors: yes
register: zypper_pkg_conflict

- assert:
that:
- zypper_pkg_conflict is failed
- "'conflicts with netcat-openbsd provided' in zypper_pkg_conflict.stdout"

- name: retry installation of gnu-netcat with force_resolution set to choose a resolution
zypper:
name: gnu-netcat
state: present
force_resolution: True