Skip to content

add shell (fnmatch) style pattern support for the apt module#3569

Closed
mvo5 wants to merge 3 commits intoansible:develfrom
mvo5:feature/apt-fnmatch
Closed

add shell (fnmatch) style pattern support for the apt module#3569
mvo5 wants to merge 3 commits intoansible:develfrom
mvo5:feature/apt-fnmatch

Conversation

@mvo5
Copy link
Contributor

@mvo5 mvo5 commented Jul 17, 2013

This branch adds support to install multiple packages via fnmatch style patterns in the "apt" module.

Our use-case is that for a university lab we want to install all r-cran-* packages and this seems to be the simplest way of doing it. The alternative would be to have a "apt_facts" module that exposes the apt cache information maybe? I'm happy to explore that option if you prefer it, but the approach in this branch looks simpler to understand in a playbook.

Feedback welcome!

Thanks,
Michael

@mpdehaan
Copy link
Contributor

Happy to test this, though may I request list comprehensions rather than lambda/filter?

Makes things a bit more readable IMHO and also will help us out when these are later deprecated, should we want to make Python 3 versions.

I'd like to avoid apt_facts if possible.

@mvo5
Copy link
Contributor Author

mvo5 commented Jul 18, 2013

Thanks, I updated the code now to avoid the lambda/filter.

To test you can e.g. run
$ ansible -m apt -a pkg='apt*' test-host
and it should try to install a bunch of apt releated pkgs

With "pkg='apt*:i386'" on a modern amd64 ubuntu you should get a bunch of i386 packages that match the pattern.

@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 6, 2013

Looks like this needs to be rebased due to changes in the apt module, can you take care of that?

Thanks!

@mvo5
Copy link
Contributor Author

mvo5 commented Aug 8, 2013

I update the branch now. Please let me know if more is needed.

@mvo5
Copy link
Contributor Author

mvo5 commented Aug 8, 2013

Hm, I did a git merge instead of a git rebase, let me see if I can fix this, otherwise I will push a new branch. Sorry for that.

@mpdehaan
Copy link
Contributor

Yeah you may be able to fix with a force push, but I'm not sure.

I will let you resubmit this one. Thanks!

@mpdehaan mpdehaan closed this Aug 10, 2013
@uvizhe
Copy link

uvizhe commented Oct 18, 2013

This commit breaks the ability to install the latest version of package using :
apt: pkg=foo=*
which is valid apt-get action:
apt-get install foo=*

@mvo5
Copy link
Contributor Author

mvo5 commented Oct 18, 2013

@uvizhe apt: pkg=foo will install the latest already, no? unless you use a special /etc/apt/preferences policy of course.

@uvizhe
Copy link

uvizhe commented Oct 18, 2013

@mvo5 sure pkg=foo installs the latest. But when you specify package version in variable and you don't know which is the latest this (foo=*) is the only possibility AFAIK. You can't leave variable empty since "apt: pkg=foo=" is illegal in Ansible.

@mvo5
Copy link
Contributor Author

mvo5 commented Oct 19, 2013

On Fri, Oct 18, 2013 at 04:40:09AM -0700, uvizhe wrote:

@mvo5 sure pkg=foo installs the latest. But when you specify package version in variable and you don't know which is the latest this (foo=*) is the only possibility AFAIK. You can't leave variable empty since "apt: pkg=foo=" is illegal in Ansible.

Aha, thanks. Now I understand your use case. I think that "apt:
pkg=foo=newest" (or candidate or installed) depending on what you
kind will work. This works on the apt commandline and I don't see why
it would not work with the ansible module (can't test right now as I'm
traveling).

Cheers,
Michael

@uvizhe
Copy link

uvizhe commented Oct 21, 2013

@mvo5 thanks! This magically works!

jimi-c pushed a commit that referenced this pull request Dec 6, 2016
The policycoreutils python API for RHEL6 and RHEL7 are sufficiently
different, requiring some additional definitions and specific conversion
that works on old and new implementations.

It also implements a fix for non-ascii error messages (like when using a
French locale configuration).

This fixes #3551.
robinro pushed a commit to robinro/ansible that referenced this pull request Dec 9, 2016
The policycoreutils python API for RHEL6 and RHEL7 are sufficiently
different, requiring some additional definitions and specific conversion
that works on old and new implementations.

It also implements a fix for non-ascii error messages (like when using a
French locale configuration).

This fixes ansible#3551.
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 4, 2018
@dagwieers dagwieers added the packaging Packaging category label Mar 3, 2019
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature This issue/PR relates to a feature request. packaging Packaging category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants