1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
Commit graph

1445 commits

Author SHA1 Message Date
Ross Williams
5f94eac41f pkgng: fix #3428; install from local file
Fixes a bug in which the module reported failure
when installing from a local (to the target host)
file path.

Fixes #3428
2021-10-13 19:21:59 +00:00
Ross Williams
75212ad73d pkgng: clean up test package creation
Make pkg json manifest more readable. Create package using
FreeBSD's `pkg create` instead of manually using tar. This
change also simplifies the manifest to a single file for
the integration test role.
2021-10-13 17:51:12 +00:00
Ross Williams
ad42951b66 pkgng: add tests for chroot and rootdir params
Refactor install tasks into an include file so they
can be reused and tested with various parameters.
2021-10-13 13:56:08 +00:00
Ross Williams
220b7e08b6 pkgng: test pkgsite parameter 2021-10-13 12:44:24 +00:00
Ross Williams
a52f4bb4a4 pkgng: Ansible 2.9 has no "false" Jinja2 test
Apparently Ansible 2.9 doesn't have the "false" test
in Jinja2 contexts. Switching to use `rejectattr(...)`
instead of `selectattr(..., "false")`.
2021-10-13 12:23:46 +00:00
Ross Williams
10a4f5ffcc pkgng: convert generator to list for 2.9
Ansible 2.9 can't count items from a generator,
so convert `select` filter output via `list`
before passing to `count`.
2021-10-13 11:14:11 +00:00
Ross Williams
b34aa1326e pkgng: make integration test package more flexible
Make integration test package building template-based,
so more flexible if in the future the name of the test package,
currently `zsh`, must change.
2021-10-13 02:24:45 +00:00
Ross Williams
32ce141397 pkgng: add test prepare task
Make sure test environment does not contain the
test package.
2021-10-13 02:24:45 +00:00
Ross Williams
074d3da9bf
pkgng: Fix changelog fragment quote formatting
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-12 21:01:09 -04:00
Ross Williams
ec47f43f79 pkgng: oops, pkgsite should be from closure
I put `pkgsite` as a keyword argument to `run_pkgng()',
which wasn't correct at all and resulted it in capturing
the second positional argument given by any caller.

`pkgsite` should have been `p["pkgsite"]`, coming from the
closure environment of `main()`.
2021-10-13 00:50:01 +00:00
Ross Williams
c34df85eac pkgng: fix syntax for Python 2
Seems *args, **kwargs have to be the last
two arguments in Python 2 syntax. CI sanity
tests were failing.
2021-10-13 00:13:40 +00:00
Ross Williams
4b10f5e1fb pkgng: update documentation to match annotate type
Missed updating the documentation to match the change
of the annotate parameter from comma-separated string
to list of strings.
2021-10-12 21:23:04 +00:00
Ross Williams
ec03bc1a2a pkgng: call module.run_command with list
Instead of calling `run_command` with a formatted
string, call it with a list to maintain safer argument
separation.

Also, introduce a wrapper for `run_command`, `run_pkgng`,
which manages the process environment and some common
command line switches, based upon the module parameters.

Introduced in this commit, also pass annotation values
to `pkg annotate` via stdin, which is safer with long
values than putting them in argv.
2021-10-12 21:15:25 +00:00
Ross Williams
4c5239e82f pkgng: fix check_mode for annotate
Actions specified in the `annotate` parameter would
always be performed, even if `check_mode=yes`.

This commit fixes `check_mode` for the annotation
functions and adds integration tests to ensure that
check mode is honored in the future.
2021-10-12 18:37:39 +00:00
Ross Williams
8f013549fd pkgng: test invalid annotate strings
Ensure that some likely to occur, invalid strings
given to the annotate module parameter 1. fail,
2. do not cause an exception, and 3. do not create
any actual annotations on packages.
2021-10-12 18:33:05 +00:00
Ross Williams
b872b294fd pkgng: test multiple annotations
Test multiple annotations specified both in new (YAML list)
syntax and old (comma-delimited) syntax.

Rename some annotation test tags from the single-annotation
tests to make sure that single and multiple annotation tests
don't collide.
2021-10-12 18:09:33 +00:00
Ross Williams
ec57903882 pkgng: fix annotation operations
Annotation has been broken at least since the migration to
collections. There are some breaking typos and function argument
omissions in the code with nothing in `git blame` but "Initial commit".

New integration tests uncovered this breakage. Works now.
2021-10-12 17:49:39 +00:00
Ross Williams
8453c368c1 pkgng: test annotation for single package
Add/modify/remove annotation for a single package
2021-10-12 15:03:25 +00:00
Ross Williams
6c5f9810b0 pkgng: pass tests when package dependencies change
Tests that install packages with dependencies were failing
when those dependencies were not already installed, because
the count of installed packages was greater than the count
of requested to be installed packages. This change checks
for a count of installed packages that is greater than or
equal to the count of requested to be installed packages.

Example:
  - Test installs packages `zsh` and `fish`
  - `fish` has a dependency on `pcre2`
  - `pkg` reports `Number of packages to be installed: 3`
2021-10-12 13:43:05 +00:00
Ross Williams
406683383e pkgng: test jail creation logging less verbose
`ezjail-admin` had been spewing every filename copied
into the jail onto stderr, making the `ansible-test -v`
logs hard to scroll through. Changed it so that ezjail
output only shows up in the ansible task logs if
`ansible_verbosity > 1` (`-vv...`). Full `ezjail-admin`
output is always logged to `/tmp/ezjail.log`.
2021-10-12 12:57:53 +00:00
Ross Williams
a803240941 pkgng: test autoremove=yes only on FreeBSD > 12
The CI test runner on FreeBSD 12.0 times out when
downloading large packages.
2021-10-12 01:52:30 +00:00
Ross Williams
4f18ef5ba6 pkgng: add test for autoremove=yes
Install package with known dependencies, then
remove it and ask autoremove to run.
2021-10-11 19:55:28 +00:00
Ross Williams
aa88d68ebc pkgng: use YAML lists for multiple packages
I had been following the documentation examples, and
specifiying multiple packages on one line. The right way
to do it is with YAML list syntax.
2021-10-11 19:28:26 +00:00
Ross Williams
98ccc58ba0 pkgng: test state=latest for mixed install/upgrade
Test that a list of packages given, one not installed
and one installed but out-of-date are handled correctly.
2021-10-11 19:25:06 +00:00
Ross Williams
3e0eb392d1 pkgng: handle space- and comma-separated lists
The module expects a list of strings in the `name` parameter,
but long-standing documentation showed space- and comma-delimited
lists as a valid way of telling the module to act on multiple
packages. Passing these lists through to the `pkg` command can
have unexpected side-effects of upgrading packages when
`state=present` rather than `state=latest` and could result
in the module reporting the wrong number of packages for each
action performed.
2021-10-11 19:19:06 +00:00
Ross Williams
73eafc126f pkgng: test install multiple packages
Multiple packages should install with a single
invocation of the `pkg` utility.
2021-10-11 18:14:38 +00:00
Ross Williams
8805f408d6 pkgng: refactor tests for task reuse
Several tests need to install an out-of-date package
to test whether upgrades occur successfully, so this
commit refactors out the generation of the test package.

Also, factor out things like the name and path of the
test package so that is more maintainable should the
target test package (currently `zsh`) ever need to
change.
2021-10-11 17:10:35 +00:00
Ross Williams
d075c83ff2 pkgng: move FreeBSD tasks to imported file
Refactoring tests for more reuse and easier
readability.
2021-10-11 16:24:08 +00:00
Ross Williams
5b13caa2d3 pkgng: test pkg works on any FreeBSD version
Removing `ansible_distribution_version`, because the
test out-of-date zsh package should install on any
FreeBSD version.
2021-10-11 16:03:25 +00:00
Ross Williams
c38eeeda0a pkgng: add cached=yes test
Changed idempotency test, because this covers both.
2021-10-11 12:49:47 +00:00
Ross Williams
d54f84f227 pkgng: refactor upgraded pattern matching
Implement russoz's suggestion to put all
variants in the pattern.
2021-10-11 02:12:35 +00:00
Ross Williams
752817cf5a pkgng: refactor renaming test package manifests
refactored to make intent of adding '+' sign clearer
2021-10-11 02:11:26 +00:00
Ross Williams
0eb4c8221c pkgng: CI seems to dislike plus-signs in filenames 2021-10-11 02:11:26 +00:00
Ross Williams
68a1332a3f pkgng: use hand-generated test package
Instead of relying on a broken-ish installation
of an older package from FreeBSD 11, hand-generate
a package named `zsh` with no contents and a version
number of `0`. It can be installed on any architecture
and any revision of FreeBSD sucessfully, and it will
always be eligible for upgrade.
2021-10-11 02:11:26 +00:00
Ross Williams
7f30ac8a5b pkgng: add state=latest test
Including small filesize out-of-date package from
FreeBSD 11 package repository, because FreeBSD 11 is
currently EOL. This test might fail at some point in the
future if the pkg utility in a FreeBSD version > 14
makes breaking changes that prevents it from installing
older package formats.

If that occurs, the fix is to replace
`files/freebsd-release-manifests-20210413__FreeBSD_11.pkg`
with the version of freebsd-release-manifests from the oldest
non-breaking release of FreeBSD, and update the
references to it in tasks/main.yml accordingly.
2021-10-11 02:11:26 +00:00
Ross Williams
1654a70825 pkgng: add state=latest idemptency test
Add test between state=present and
state=absent that ensures state=latest runs
successfully on an already up-to-date package
with changed=false.
2021-10-11 02:11:26 +00:00
Ross Williams
9a867a38ee pkgng: add state=absent test
Also renumber `jail=...` test to make diffs less
noisy when adding more non-jailed tests.
2021-10-11 02:11:26 +00:00
Ross Williams
840cb8f408 pkgng: remove redundant test for docker container
These tests should be skip/docker, but the test
playbook also redundantly checked whether it was
running in a docker container.

Checking whether `ansible_facts.distribution` is
`FreeBSD` is really sufficient to be sure whether
the test is running in an environment that supports
the `pkgng` module.
2021-10-11 02:11:26 +00:00
Ross Williams
867b7d5bee pkgng: test with zsh not bash package
Had been using bash package, because it's not
likely to disappear from the package repository
any time soon. Turns out that bash is already
installed on the Ansible community.general
FreeBSD CI VM image, which makes the test fail.

Zsh probably isn't going away any time soon,
either, and likely won't be installed on the
CI image.
2021-10-11 02:11:26 +00:00
Ross Williams
bfdaed0ce5 pkgng: add basic integration tests
Test installing a package
Test installing a package into a jail
2021-10-11 02:11:26 +00:00
Ross Williams
5aff694dc4 pkgng: check_mode should count queued actions
Writing tests caught a bug in PR #3393, which enabled
installing more than one package per `pkg` execution.

In converting the module's install/upgrade code to a
queue structure, check_mode got broken because the count
of actions performed was only updated in the `if not check_mode`
block that invokes `pkg`. This two-line change counts
the number of actions in the queue when check mode is
enabled.
2021-10-11 02:11:26 +00:00
Ross Williams
4fe3aea3a9 pkgng: package reinstallations count as changed
`upgrade_packages()` only looked for the string
"Number of packages to be upgraded", but the
`pkg upgrade` command also reports "Number of packages to be
reinstalled". Reinstallation occurs when package metadata other
than version changes (e.g. build options, single architecture to `*`
architecture). In any other respect, though, a required
reinstallation is the same as an upgrade.
2021-10-11 02:09:06 +00:00
Laurent Paumier
9de01e04f2
keycloak_role: quote role name in urls (#3536)
* quote role name in urls

* add changelog fragment

* Update changelogs/fragments/3536-quote-role-name-in-url.yml

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* fix linefeeds

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-10-09 13:38:02 +02:00
Felix Fontein
d1f820ed06
Fix shellcheck error. (#3531) 2021-10-08 15:09:47 +02:00
Ross Williams
293c7a9fb3
Pkgng many packages one command (#3393)
* pkgng: join package list into one command

Change the pkgng module so all packages being
installed (or upgraded) are acted on in one
command (per action). This will make installs
and upgrades a bit faster, because pkg will be
invoked fewer times per module run. More important,
module actions will be more atomic, making it less
likely that some packages are acted on because they
appear earlier in the argument list.

This change also improves the status reporting of
packages acted on, specifying the number of packages
for each action (install or upgrade).

* pkgng: make upgrade check lazily evaluated

Make upgrade_available an inner function so that the
if statement that checks whether installed packages
are up-to-date only runs the upgrade check on packages
that are already installed. This gets lazily evaluated
because of boolean operator short-circuiting:
https://docs.python.org/3.8/library/stdtypes.html#boolean-operations-and-or-not

Previously, the module would always check for upgrades,
even for not-installed packages, when running with
`state=latest`.

* pkgng: add changelog fragment

* pkgng: Apply changelog suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* pkgng: resolve pep8 style issue

Remove inline function. It's purpose would be confusing for
future maintainers, and someone refactoring it to a variable,
with good intentions, would introduce a performance regression.

Including the `query_update()` call in the if expression makes
the intent more legible and still ensures lazy evaluation of the
function call if the first `and` is `False`.

* pkgng: Fix changelog fragment syntax issue

Need to escape quotes so YAML doesn't eat them

Co-authored-by: Felix Fontein <felix@fontein.de>

* pkgng: Improve output message English grammar

Make word "package" plural only if reporting on more than one package

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-08 07:41:56 +02:00
Dominik Wombacher
f0fcb221cd
zypper_repository: Improve .repo file idempotency (#3474)
* If repo option points to .repo file, download for later parsing

* Parse downloaded .repo file content (ini format)

* Validate downloaded file, map values to repodata, workaround to ignore old .repo related code

* Integration Test adjusted to install python package 'requests' first

* Revert "Integration Test adjusted to install python package 'requests' first"

This reverts commit 0d18352c2238d098831ba6d59b66e731fa8f0cd9.
Not allowed to introduce new dependencies at this point, module_utils usage required

* Remove python 'requests' dependency, using 'fetch_url' and 'to_text' from 'ansible.module_utils' instead

* Prefer alias (name) if given instead repo (url)

* If gpgkey was given in .repo file ensure key get automatically imported

* ConfigParser Import made Python2 compatible

* New .repo code moved below existing run-time parameters checks to keep previous logic

* Obsolete workaround removed

* two pylint/pep8 errors fixed

* name added to autorefresh assert

* Missing assert for 'Delete test repo' added

* name added to priority option assert

* name added to check repo is updated by url assert

* name added to check repo is updated by name assert

* name added to check add a repo by releasever assert

* name added to check remove added repo assert

* name added to check add a repo by basearch assert

* name added to check remove added repo #2 assert

* Bugfix to avoid 'KeyError' Exception in if statements

* Refactoring of configparser related code, usage of module_utils, py2 compatibility

* Removal of some leftover from earlier testing

* Integration tests for add/remove repositories by url to .repo file added

* Additional name added to list of test repos that has to be removed

* Test added to verify cleanup of local .repo file after removal via zypper

* Changelog fragment related to PR #3474 added

* yamllint error resolved

* Refactoring to reduce indentation and removal of else statements

* Integration tests added for loading .repo file from local path

* Test .repo file added

* Dependency to setup_remote_tmp_dir added

* New entry added to 'remove repositories added during test'

* Support for .repo file from local path

* Changelog: Ref to https://github.com/ansible-collections/community.general/issues/3466 added

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-08 07:40:30 +02:00
Greg
80bb42325b
[ufw] Insert or delete biased when deletion enabled - as for append or delete. (#3514)
* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.

* [ufw] Insert or delete biased when deletion enabled - as for append or delete.
2021-10-07 15:31:38 +02:00
Victor Martinez
3a460751a4
[opentelemetry][callback] add option to support enabling plugin in the CI (#3498)
* [opentelemetry][callback] add option to support enabling plugin in the CI only

* [opentelemetry][callback] add changelog fragment

* Apply suggestions from code review

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* [opentelemetry][callback] use enable_from_environment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* [opentelemetry] ensure the value is true otherwise the plugin is not enabled

* [opentelemetry][changelog] update entry with the new option

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-07 15:31:08 +02:00
Victor Martinez
e22fff2b12
[opentelemetry][callback] enrich stacktrace errors (#3496)
* [opentelemetry][callback] refactor get_error_message and add UTs

* [opentelemetry][callback] enrich exception with msg, exception and stderr fields

* [opentelemetry] fix linting

* [opentelemetry][callback] add changelog fragment

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* [opentelemetry][callback] chore: remove comment

* [opentelemetry][callback] refactor tests

* [opentelemetry] refactor UTs

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-10-07 06:59:03 +02:00
Frank Dornheim
57e5f8c7be
lxd_container: improvements to the comments (#3520)
* improvements to the comments

* next documentation improvements

Co-authored-by: Frank Dornheim <“dornheim@posteo.de@users.noreply.github.com”>
2021-10-07 06:57:45 +02:00