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

package: version specifiers only work with yum #29705

Closed
ansibot opened this issue Sep 11, 2017 · 8 comments
Closed

package: version specifiers only work with yum #29705

ansibot opened this issue Sep 11, 2017 · 8 comments
Labels
affects_2.1 This issue/PR affects Ansible v2.1 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@ansibot
Copy link
Contributor

ansibot commented Sep 11, 2017

From @riccardomurri on 2016-08-19T14:14:21Z

ISSUE TYPE
  • Bug Report
COMPONENT NAME

package module

ANSIBLE VERSION
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

No changes to the stock ansible.cfg, and no settings in the environment either:

env | fgrep ANSIBLE_ -c
0
OS / ENVIRONMENT

Ubuntu 16.04 (xenial)

SUMMARY

Documentation for the OS-independent package module states that name=
can be a "package specifier with version, like name-1.0". The - however is not
considered a package/version separator by the apt module, which uses =
instead, and the package module does not translate it.

In short, invocation of package: name=foo-1.0 state=present use=apt makes
Ansible try to install package foo-1.0 instead of ensuring that package foo
is installed at version 1.0

STEPS TO REPRODUCE

Package lmod is installed on my system and is version 5.8:

dpkg -l lmod
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
ii  lmod                                      5.8-1                     all                       Lua based environment modules

However, if I try to check it with Ansible I get an error:

$ sudo ansible localhost -m package -a "name='lmod-5.8' state=present use=apt"
localhost | FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "No package matching 'lmod-5.8' is available"
}

Using apt-compatible syntax works, but that defeats the purpose of an
OS-independent package manager:

$ sudo ansible localhost -m package -a "name='lmod=5.8*' state=present use=apt"
localhost | SUCCESS => {
    "cache_update_time": 0,
    "cache_updated": false,
    "changed": false
}
EXPECTED RESULTS

That the package version specifiers are translated to the appropriate syntax for
the apt or yum or whatever module Ansible's package module is using under
the hood.

Copied from original issue: ansible/ansible-modules-core#4472

@ansibot
Copy link
Contributor Author

ansibot commented Sep 11, 2017

From @ansibot on 2016-08-19T14:14:21Z

@ansible ping, this issue is waiting for your response.
click here for bot help

@ansibot ansibot added the affects_2.1 This issue/PR affects Ansible v2.1 label Sep 11, 2017
@ansibot
Copy link
Contributor Author

ansibot commented Sep 11, 2017

From @riccardomurri on 2016-08-19T14:14:21Z

Currently I use the following workaround: early in the playbook I set a variable
__at__ to the value '-' on OSes that use yum, and to the value '=' on
Debian/Ubuntu.

Then I call the package module like this::

package:
  name='foo{{__at__}}version'
  state=present

(It's relatively straightforward, but may save someone a few minutes' time to
find it here.)

@ansibot ansibot added bug_report module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 11, 2017
@abelgana
Copy link

abelgana commented Oct 9, 2017

Hi,

I will try to work on the issue. I just cloned the repos. I think this is where the function is defined:

https://github.com/ansible/ansible/blob/13631ececa4454397821d3805f4079d8cc157f33/lib/ansible/modules/packaging/os/yum.py

@ansibot ansibot removed the needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) label Nov 18, 2017
@robertdebock
Copy link
Contributor

I've seen exactly the same, here are some details for reproducibility:

Failed: (using "-")

ansible -m package -a "name=libsemanage-common-2.3-1" reference-debian-8
reference-debian-8 | FAILED! => {
    "changed": false, 
    "msg": "No package matching 'libsemanage-common-2.3-1' is available"

Success: (using "=")

ansible -m package -a "name=libsemanage-common=2.3-1" reference-debian-8
reference-debian-8 | SUCCESS => {
    "cache_update_time": 1516107446, 
    "cache_updated": false, 
    "changed": false
}

I think an update to the documentation can help, although it would be better to change the module.

I'll make a merge request for fixing the documentation.

@bcoca
Copy link
Member

bcoca commented Feb 9, 2018

the package module just passes the parameters through to 'detected' packaging module for that system, it does not know, nor should it, about package names nor version specifiers.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
robertdebock added a commit to robertdebock/ansible-role-mssql that referenced this issue Mar 8, 2018
@ansibot ansibot added the packaging Packaging category label Feb 17, 2019
@ansibot ansibot added the has_pr This issue has an associated PR. label Jul 28, 2019
@ansibot ansibot added the needs_triage Needs a first human triage before being processed. label May 16, 2020
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label May 18, 2020
@bcoca
Copy link
Member

bcoca commented May 21, 2021

closing as per above

@bcoca bcoca closed this as completed May 21, 2021
@riccardomurri
Copy link
Contributor

he package module just passes the parameters through to 'detected' packaging module for that system, it does not know, nor should it, about package names nor version specifiers.

I would say this limits the utility of the package module as a distro-independent way of installing packages. A great part of the utility of package: comes from the fact that I do not need to care whether the distro uses apt or yum; if I need to care b/c the syntax for specifying package version varies, then I might as well drop package: completely and use apt: or yum: directly...

@sivel
Copy link
Member

sivel commented May 21, 2021

We actually recommend not using package for anything other than the most basic of uses. Anything more complex than a simple name: foo should probably be using the individual modules directly instead.

@ansible ansible locked and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.1 This issue/PR affects Ansible v2.1 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

7 participants