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

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants
@mvo5
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@mpdehaan

mpdehaan Jul 18, 2013

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.

Contributor

mpdehaan commented Jul 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@mvo5

mvo5 Jul 18, 2013

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@mpdehaan

mpdehaan Aug 6, 2013

Contributor

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

Thanks!

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

This comment has been minimized.

Show comment
Hide comment
@mvo5

mvo5 Aug 8, 2013

Contributor

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

Contributor

mvo5 commented Aug 8, 2013

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

@mvo5

This comment has been minimized.

Show comment
Hide comment
@mvo5

mvo5 Aug 8, 2013

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@mpdehaan

mpdehaan Aug 10, 2013

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!

Contributor

mpdehaan commented Aug 10, 2013

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

This comment has been minimized.

Show comment
Hide comment
@uvizhe

uvizhe 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=*

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

This comment has been minimized.

Show comment
Hide comment
@mvo5

mvo5 Oct 18, 2013

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@uvizhe

uvizhe 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.

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

This comment has been minimized.

Show comment
Hide comment
@mvo5

mvo5 Oct 19, 2013

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@uvizhe

uvizhe Oct 21, 2013

@mvo5 thanks! This magically works!

uvizhe commented Oct 21, 2013

@mvo5 thanks! This magically works!

jimi-c pushed a commit that referenced this pull request Dec 6, 2016

Bugfix for newer policycoreutils-python (eg. RHEL7) (#3569)
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

Bugfix for newer policycoreutils-python (eg. RHEL7) (#3569)
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.

@ansibot ansibot added feature and removed feature_pull_request labels Mar 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment