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 module expands to <pkg>-<version definition> AND <pkg> #23516

Closed
Popyllol opened this issue Apr 12, 2017 · 6 comments · Fixed by #24056
Closed

zypper module expands to <pkg>-<version definition> AND <pkg> #23516

Popyllol opened this issue Apr 12, 2017 · 6 comments · Fixed by #24056
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. module This issue/PR relates to a module. packaging Packaging category

Comments

@Popyllol
Copy link

  • Bug Report
COMPONENT NAME

zypper_module

ANSIBLE VERSION
ansible 2.2.1.0
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

I have in a role a tasks/main.yml which contains:

  - include: library/setup_packages.yml
    vars:
      pkg:   "{{ item }}"
      state: present
    with_items:
      - "{{ wanted_packages | default([]) }}"
    tags:
      - packages

and a library/setup_packages.yml which contains:

---
  - debug:
      msg:   "{{ pkg }} -> {{ state }}"

  - zypper:
      pkg:   "{{ pkg }}"
      state: "{{ state }}"

When I call this with a list wanted_packages like this:
wanted_packages:

  • rlwrap=0.37-2.1

This fails for me because there are two versions of rlwrap in the repository directory. Only the older one is installable in my context. So I tried to set a specific version. But the zypper module generates a commandline with both "rlwrap=0.37-2.1" AND "rlwrap" which leads into a failure.
The output is:

TASK [oracle : debug] **********************************************************
ok: [hhlokora12-tpl] => {
    "msg": "rlwrap=0.37-2.1 -> present"
}

TASK [oracle : zypper] *********************************************************
fatal: [hhlokora12-tpl]: FAILED! => {"changed": false, "cmd": ["/usr/bin/zypper", "--quiet", "--non-interactive", "--xmlout", "install", "--type", "package", "--auto-agree-with-licenses", "--no-recommends", "--oldpackage", "--", "rlwrap=0.37-2.1", "rlwrap"], "failed": true, "msg": "Zypper run command failed with return code 4.", "rc": 4, "stderr": "", "stdout": "<?xml version='1.0'?>\n<stream>\n<prompt id=\"1\">\n<description>Problem: nothing provides libreadline.so.5()(64bit) needed by rlwrap-0.42-24.1.x86_64\n Solution 1: do not install rlwrap-0.42-24.1.x86_64\n Solution 2: break rlwrap-0.42-24.1.x86_64 by ignoring some of its dependencies\n</description>\n<text>Choose from above solutions by number or cancel</text>\n<option value=\"1\" desc=\"\"/>\n<option value=\"2\" desc=\"\"/>\n<option default=\"1\" value=\"c\" desc=\"\"/>\n</prompt>\n</stream>\n", "stdout_lines": ["<?xml version='1.0'?>", "<stream>", "<prompt id=\"1\">", "<description>Problem: nothing provides libreadline.so.5()(64bit) needed by rlwrap-0.42-24.1.x86_64", " Solution 1: do not install rlwrap-0.42-24.1.x86_64", " Solution 2: break rlwrap-0.42-24.1.x86_64 by ignoring some of its dependencies", "</description>", "<text>Choose from above solutions by number or cancel</text>", "<option value=\"1\" desc=\"\"/>", "<option value=\"2\" desc=\"\"/>", "<option default=\"1\" value=\"c\" desc=\"\"/>", "</prompt>", "</stream>"]}

Why is it expanding to both?
If it is needed a switch like exact_version or so which leads only to the specific version would be nice.

STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

@ansibot
Copy link
Contributor

ansibot commented Apr 12, 2017

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Apr 12, 2017
@robinro
Copy link
Contributor

robinro commented Apr 13, 2017

@Popyllol Thanks for this bug report.
The duplication is unintentional, but harmless in most usecases (except yours).

It happens in
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/zypper.py#L370-L378

One should either remove the versioned entries from name_install or combine install_version and name_install in one variable. The version code was added on top later, and is not well integrated.

Do you want to have a go at fixing this?
needs_contributor

@Popyllol
Copy link
Author

Thanks for you investigation so far!
But sorry, I am not your man if the code is Python :-(. Still a blind spot in my languages.
If one can fix this I would be glad :-).

@robinro
Copy link
Contributor

robinro commented Apr 13, 2017

If someone else can have a go I'd be happy to help/review.

If not I'll probably fix it myself some time in the future.

@ansibot ansibot added waiting_on_contributor This would be accepted but there are no plans to actively work on it. and removed needs_triage Needs a first human triage before being processed. labels Apr 13, 2017
albertomurillo pushed a commit to albertomurillo/ansible that referenced this issue Apr 24, 2017
Remove packages found in install_version from name_install.

Fixes ansible#23516

Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
@albertomurillo
Copy link
Contributor

@Popyllol Can u test this patch? I do not have an environment with suse and two repos with different version of the same package. But I did check that the versioned package is included once in the cmdline and not twice as before.

@albertomurillo
Copy link
Contributor

@robinro I made a patch for this issue, can u review it?
#23936

robinro pushed a commit to robinro/ansible that referenced this issue Apr 28, 2017
almonteb pushed a commit to almonteb/ansible that referenced this issue May 25, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@dagwieers dagwieers added the packaging Packaging category label Mar 3, 2019
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
@sivel sivel removed the waiting_on_contributor This would be accepted but there are no plans to actively work on it. label Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. module This issue/PR relates to a module. packaging Packaging category
Projects
None yet
6 participants