modules/apt: add support for apt-patterns#83070
modules/apt: add support for apt-patterns#83070jmechnich wants to merge 3 commits intoansible:develfrom
Conversation
|
|
||
| pkgname_pattern, version_cmp, version = package_split(pkgspec_pattern) | ||
|
|
||
| if pkgname_pattern.startswith(('?', '~', '(?', '(~')): |
There was a problem hiding this comment.
@jmechnich Do you mind adding an integration test for this change? I am not quite sure if I understand how this change works.
There was a problem hiding this comment.
@Akasurde I cannot really think of a way to test this without actually calling apt-get or similar in a appropriately set up OS. Right now, the tests emulate certain operations using an artificial package cache.
The general idea of this patch is to exclude package names starting with ? or ~ from normal processing as they are not legal patterns for i.e. apt-cache operations.
The issue with testing this in the realm of ansible is mainly that the effect of those patterns is determined on each target host, individually, at execution time.
Maybe it is sufficient that the other tests are still working as expected?
There was a problem hiding this comment.
@Akasurde sorry for reviving this old PR after such a long time...is there anything I can still do to get this accepted?
6f7f855 to
316fb21
Compare
316fb21 to
0a9feef
Compare
SUMMARY
This small patch adds support for apt-patterns.
ISSUE TYPE
ADDITIONAL INFORMATION
Support for apt-patterns makes it possible e.g. to express
apt purge ?config-filesusing theaptmodule in contrast to working around usingshell.Only when using
state=absent, the apt-pattern will end up as-is in the final call to apt on the remote machine as this is the most relevant use case for us and also in the examples of the apt-patterns man page. It is certainly possible to generalize for other packages states if required.Example call:
ansible -m apt -a "name=?config-files state=absent autoremove=yes purge=yes" ...will purge remnant configuration files from removed packages as well as unused packages in one call.