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

769 commits

Author SHA1 Message Date
Waldek Maleska
8ba7fd5d61
fix gitlab_deploy_key task in check mode (#3622)
fixes #3621

* running check mode used to accidentally delete the existing
  ssh key; change it so deletion is skipped in check mode
2021-10-28 20:07:05 +02:00
Victor Martinez
a362879ff6
[opentelemetry][callback] Support loops error handling (#3599)
* [opentelemetry][callback] simplify condition

* [opentelemetry][callback] initial support for loops

* [opentelemetry][callback] support for loops

* [opentelemetry][callback] enrich loop message with action and item

* [opentelemetry][callback] add UTs for get_error_message_from_results

* [opentelemetry][callback] add UTs for enrich_error_message_from_results

* [opentelemetry][callback] add changelog fragment

* Update plugins/callback/opentelemetry.py

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

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-10-27 07:51:49 +02:00
Victor Martinez
7e1412e5e1
[opentelemetry][callback] transform args attribute in a list of attributes with redacted user/pass in URL values (#3564)
* [callback][opentelemetry] list of attributes for arguments

* [opentelemetry][callback] list of attributes for the args and redact user/pass from http

* [opentelemetry][callback] remove unused imports

* [opentelemetry][callback] fix E713

* [opentelemetry][callback] remove unused static method

* [opentelemetry][callback] remove duplicated functions

* Apply suggestions from code review

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

* [opentelemetry][callback] fix ident

* [opentelemetry][callback] add changelog fragment

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-10-24 19:00:00 +02:00
Pierre Dumuid
996dc617ed
Keycloak module cleanup and consistency (#3280)
* Consistent Modules - Rename updated_?? to desired_?? in all the keycloak modules.

* Consistent Modules - Rename the comments, and add whitespace so that all the modules are a lot more consistent between each other.

* Consistent Modules - Remove final elif where a final else doesn't exist.

This is to address the inconsistency between the other modules.

Whilst I can see it being more descriptive, there should be a final "else:" to cater if the values is neither 'absent' or 'present'.

* Consistent Modules - Use dict() instead of {} like most of the other keycloak modules.

* Consistent Modules - Update keycloak authentication so that the if ordering is consistent for no-item.

* Consistent Modules - Move the 'Filter and map' process to always occur before getting an existing item.

* Consistent Modules - Be consistent with how to initialse before_?? and set it to dict() if it is None.

* Consistent Modules - Add module.exit_?? in the locations as per the other modules.

* Consistent Modules - Represent result['diff'] using dict(before=.., after=...) as per all the other modules.

* Consistent Modules - Add / Move location of when result['end_state'] is getting defined.

* Consistent modules - Add result['changed'] = False where we do nothing and exit because item exists.

* Consistent Modules - Set the value result['changed'] to True earlier so it shows up when in checking mode only.

* Consistent Modules - test for equality with a dict to assert there was no realm in the first place as per the other modules.

* Consistent Modules - Address the spelling.

* Consistent Modules - keycloak_group - Remove result['group'] as result['end_state'] is the consistent value used in the other modules.

* Consistent Modules - Order the lines in the section, Do nothing and exit consistently.

* Consistent Modules - Add result['end_state'] and still add deprecated `flow` return value.

* Consistent Modules - Add missing return documentation for `msg`.

* Consistent Modules - Tweak whitespace in the RETURN variable.

* Consistent Modules - Add result['group'] in addition to deprecated result['group'] response.

* Consistent Modules - Add return property, 'contains' to address test errors.

* Consistent Modules - Rename updated_?? to desired_?? in new modules since initial PR.

* Consistent Modules - Rename the comments, and add whitespace so that all the (recently added) modules are a lot more consistent between each other.

* Consistent Modules - Make indentation consistent within the response document.

* Consistent Modules - Use B(DEPRECATED) in a seperate line in the description.

* Consistent Modules - Add a lot of full stops to sentences.

* Consistent Modules - Use C(...) and I(...) formatting methods.

* Consistent Modules - Use "on success" everywhere for end_state response documentation.

* Consistent Modules - Update the documents for RETURN.proposed, RETURN.existing, RETURN.end_state to be the same.

* Consistent Modules - Add fragment.

* Remove period after short_description.

* Update changelog fragment.

* Consistent Modules - PRFeedback - Remove `module.exit_json(**result)` within the `Delete` section of the if statement.

There's a exit_json(..) immediately after.

* Consistent Modules - PRFeedback - Use `if not x_repr` instead of `if x_repr == dict()`.

* keycloak_authentication - Add a sample of the output.

* Replace `dict()` with `{}` for all the keycloak modules.

* Add the requested deprecated notices

* Update changelogs/fragments/3280-keycloak-module-cleanup-and-consistency.yml

Co-authored-by: Pierre Dumuid <pierre@knowyourdata.com.au>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-22 07:57:18 +02:00
Nate Coraor
86a22b5ed2
Fix exception in pkgin module when all packages are already installed (#3583)
* Fix exception in pkgin module when all packages are already installed.

* Update plugins/modules/packaging/os/pkgin.py

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

* Add changelog fragment for #3583

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-22 07:47:27 +02:00
Ross Williams
45d3661ccf
pkgng: add basic integration tests (#3526)
* 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.

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

* pkgng: add basic integration tests

Test installing a package
Test installing a package into a jail

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

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

* pkgng: add state=absent test

Also renumber `jail=...` test to make diffs less
noisy when adding more non-jailed tests.

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

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

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

* pkgng: CI seems to dislike plus-signs in filenames

* pkgng: refactor renaming test package manifests

refactored to make intent of adding '+' sign clearer

* pkgng: refactor upgraded pattern matching

Implement russoz's suggestion to put all
variants in the pattern.

* pkgng: add cached=yes test

Changed idempotency test, because this covers both.

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

* pkgng: move FreeBSD tasks to imported file

Refactoring tests for more reuse and easier
readability.

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

* pkgng: test install multiple packages

Multiple packages should install with a single
invocation of the `pkg` utility.

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

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

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

* pkgng: add test for autoremove=yes

Install package with known dependencies, then
remove it and ask autoremove to run.

* pkgng: test autoremove=yes only on FreeBSD > 12

The CI test runner on FreeBSD 12.0 times out when
downloading large packages.

* 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`.

* 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`

* pkgng: test annotation for single package

Add/modify/remove annotation for a single package

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

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

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

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

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

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

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

* 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()`.

* pkgng: Fix changelog fragment quote formatting

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

* pkgng: add test prepare task

Make sure test environment does not contain the
test package.

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

* 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`.

* 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")`.

* pkgng: test pkgsite parameter

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

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

* 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

* pkgng: changelog fragment formatting issue

* pkgng: check for all test package extensions

pkg recently changed file extensions, so for the
tests to work on multiple recent versions of FreeBSD,
we must check for `pkg create` output with varying
filename.

* Revert "pkgng: fix #3428; install from local file"

As the module has invoked pkg with the `-g` flag for
at least 7 years, I'm not sure when it was possible
to install packages from files on the target host
filesystem, because pkg rejects file paths when
the `--glob` flag is enabled.

I considered doing a rework of the pkg invocation
to enable good support for installing from local
files, but it looks like more of a job than for this PR.

This reverts commit 5f94eac41f.

* pkgng: Add minor_changes fragment for #3526

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-22 07:32:35 +02:00
Mike Raineri
481fc48e51
Redfish: Do not set the boot source override mode if not provided by the user (#3581)
* Redfish: Do not set the boot source override mode if not provided by the user

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Corrected changelog file extension

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update changelogs/fragments/3509-redfish_utils-SetOneTimeBoot-mode-fix.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-22 07:29:26 +02:00
Matyáš Kroupa
e7e2ab94da
nmcli: Fix ipv6.dns not being recongnized as list (#3563)
* nmcli: Fix ipv6.dns not being recongnized as list

There was a missing comma on the previous line.

* nmcli: Add changelog fragment for #3563

* nmcli: Update changelogs/fragments/3563-nmcli-ipv6_dns.yaml

Make the fix description more descriptive

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

* nmcli: Remove ipv4.route-metric from list-typed properties

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

* nmcli: Update fragment 3563 with ipv4.route-metric bug

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-10-21 08:05:00 +02:00
Felix Fontein
a68445486e
Remove and redirect all infoblox/nios content (#3592)
* Remove and redirect all infoblox/nios content.

* Remove ignore.txt entries.

* Update BOTMETA.
2021-10-21 08:02:06 +02:00
Mike Raineri
6580e7559b
Redfish: perform manager network interface configuration even if property is missing (#3582)
* Redfish: perform manager network interface configuration even if property is missing

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update changelogs/fragments/3404-redfish_utils-skip-manager-network-check.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-20 17:26:15 +02:00
Victor Martinez
d9e8724b1d
[callback][opentelemetry] enrich span with http attributes (#3558)
* [callback][elastic] enrich span with http attributes

* [callback][opentelemetry] fix linting

* [callback][opentelemetry] fix UTs

* [opentelemetry][changelog] add fragment for the service map feature

* Update plugins/callback/opentelemetry.py

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

* [opentelemetry][callback] remove comments

* [opentelemetry][callback] fix UTs

* [opentelemetry][callback] return the value

otherwise a None value returns ParseResultBytes when using urlparse(None)

* [opentelemetry][callback] fix wrong parameter order

* [opentelemetry][callback] support for no interpolated URLs

* [opentelemetry][callback] support for URLs without interpolation in the hostname

* [opentelemetry][callback] fix linting

* Update changelogs/fragments/3558-callback_opentelemetry-enrich_service_map.yml

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

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-20 17:24:14 +02:00
Rossen
ef0b83fdf1
ipa_group: add append option (#3545)
* ipa: add append parameter to modify_if_diff

* ipa_group: add state: append

* ipa_group: rework append to an option instead of another state

* ipa_group: append default=no

* ipa_group: add change fragment for new append option

* ipa_group: restore descriptions for group and user

* ipa_group: re-add missed quotation mark

* ipa_group: set default for append in
argument_spec

* ipa_group: add .yml ext to fragement file

* ipa_group: corrections to append description

* ipa_group: refine change fragement text

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

* ipa_group: use correct macros in option descriptions

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

* ipa_group: include append in user and group descriptions

* ipa_group: add version_added

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-19 13:36:08 +02:00
Sergey
191d2e08bb
Fix bug with returning results in IPA role (#3561)
* Fix bug with returning results in IPA role

Fix #3560

* Add changelog

* Fix typo in changelog

* Update changelogs/fragments/3561-fix-ipa-host-var-detection.yml

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Update changelogs/fragments/3561-fix-ipa-host-var-detection.yml

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Update changelogs/fragments/3561-fix-ipa-host-var-detection.yml

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

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-16 20:45:48 +02:00
Dominik Wombacher
71ea99d10f
ssh_config: Add 'forwardagent' option (#3495)
* Integration Tests for Options added, includes 'proxycommand'

* New option 'forwardagent' added to integration tests

* Missing double quotes added to 'forwardagent' values to enforce handling as string

* New option 'forwardagent' added

* yamllint error resolved

* 'forwardagent' type changed from str to choices (yes/no)

* Changelog added

* correct typo

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

* version info added to new option

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

* fix(ssh_config): option name to snake_case, type str to bool

* fix(ssh_config): convert bool true/false to str yes/no

* fix(ssh_config): rename option to 'forward_agent' in integration test

* fix(ssh_config): args key 'forwardagent' renamed to 'forward_agent'

* fix(ssh_config): 'else' replaced with 'if' statement to cover case when value is 'None'

* increase version_added to 4.0.0

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

* simplify if statement for True/False to yes/no mapping

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

* update comment to better describe functionality

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

* fix(ssh_config): avoid overwrite of existing option in case of None value

* test(ssh_config): case added to verify no changes on existing option if not given in playbook

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-14 21:24:23 +02:00
Victor Martinez
18f8195983
[callback][elastic] enrich stacktrace errors (#3556)
* [callback][elastic] enrich stacktrace errors

* [callback][elastic] add changelog fragment
2021-10-14 21:19:02 +02:00
Felix Fontein
d25554df9d
Improve opkg module (#3554)
* Allow name to be a YAML list as well, and be more lenient when splitting strings by comma.

* General docs improvements.
2021-10-14 21:14:32 +02:00
Felix Fontein
9546bbb55e
Remove deprecated options, aliases and defaults (#3461)
* Remove deprecated options, aliases and defaults.

* Add changelog fragment.

* Small fixes.

* Apply suggestions from code review

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

* Lint.

* Update plugins/modules/system/xfconf.py

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Bump galaxy version to 4.0.0.

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
2021-10-12 13:56:15 +02:00
Anand Victor
7038812465
Bugfix issue2692 logstash callbackmodule with no attribute options (#3530)
* Update logstash.py

replacing _options with context.cliargs

* Create 2692-logstash-callback-plugin-replacing_options

logstash callback plugin replace _option with context.CLIARGS

* Rename 2692-logstash-callback-plugin-replacing_options to 2692-logstash-callback-plugin-replacing_options.yml

missed out the extenstion

* Update logstash.py

context imported

* Update 2692-logstash-callback-plugin-replacing_options.yml

dict to string

* Update changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-11 22:55:18 +02:00
linxside
ed2c1e4ac9
terraform: add parallelism parameter (#3540)
* terraform: add parallelism parameter

* terraform: add parallelism parameter version
2021-10-11 22:44:20 +02:00
Laurent Paumier
d44c85aa90
keycloak_identity_provider: Fix mappers update (#3538)
* set identityprovideralias by default

* refactor mappers change detection

* fix sanity check

* update tests

* add changelog fragment

* Update changelogs/fragments/3538-fix-keycloak-idp-mappers-change-detection.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-11 22:43:50 +02:00
Aoife Finch
8ece0d3609
macports: add stdout and stderr to status (#3499) (#3500)
* macports: add stdout and stderr to status (#3499)

* Add changelog fragment

* Update changelogs/fragments/3500-macports-add-stdout-and-stderr-to-status.yaml

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

Co-authored-by: Aoife Finch <aoife@finch.ink>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-11 06:55:09 +02: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
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
Jonathan Piron
0bc4518f3b
Fix: gitlab_deploy_key idempotency (#3473)
* Fix: gitlab_deploy_key idempotency

The module was not retrieving all the deploy keys leading to non
idempotency on projects with multiple deploy keys.
SEE: https://python-gitlab.readthedocs.io/en/stable/api-usage.html#pagination

* Update changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml

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

Co-authored-by: Jonathan Piron <jonathanpiron@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-04 21:03:31 +02:00
Felix Fontein
5895e50185
yaml callback: prevent plugin from modifying PyYAML (#3478)
* Prevent yaml callback from modifying PyYAML.

* Fix changelog fragment.

* Update changelogs/fragments/3478-yaml-callback.yml

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
2021-10-01 22:42:39 +02:00
Victor Martinez
774b2f642b
[opentelemetry] minor changes in the import, docs and exception (#3450)
* OrderedDict has been added to the Python stdlib since version 2.7

* Docs: cosmetic change in the python lib

* See https://github.com/ansible/ansible/issues/75726

* Add changelog fragment

* Apply suggestions from code review

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-10-01 14:39:22 +02:00
Pan Luo
7cfdc2ce8c
Copy the permissions along with file for jboss module (#3426)
* Copy the permissions along with file for jboss module

Issue: The deployment file is copied with file content only. The file
permission is set to 440 and belongs to root user. When the
JBossI(Wildfly) server is running under non root account, it can't read
the deployment file.

With is fix, the correct permission can be set from previous task for JBoss
server to pickup the deployment file.

* Update changelogs/fragments/3426-copy-permissions-along-with-file-for-jboss-module.yml

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

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-09-29 06:51:18 +02:00
Sreekanth H
53fc2c477b
nmcli: amended the routing-rules4 key values as list (#3401)
* Updated nmcli.py

Amended the routing-rules4 values as list. By this we could add the entries for "routing_rules4" in the form of a list .

* Update nmcli.py 

Fixed typo in line #1701

* 3395-nmcli-needs-type.yml

routing_rules4 module argument is currently accepting only string elements. In order to accept multiple values, amended the type of routing_rules4 as list.

* nmcli: amended the routing-rules4 key values as list

routing_rules4 module argument is currently accepting only string elements. In the case of adding multiple entries to routing_rules4, we need to accept values as list.

* Added 3401-nmcli-needs-type.yml

routing_rules4 module argument is currently accepting only string elements. In the case of adding multiple entries to routing_rules4, we need to accept values as lists

* Amended type to 'minor_changes' 

Amended type to 'minor_changes'  from 'bug_fixes'

* routing_rules4 to a list of element str

nmcli.py - routing_rules4 to a list of element str

* Update changelogs/fragments/3401-nmcli-needs-type.yml

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

* nmcli: allow routing-rules4 key values as list

* nmcli: amended the routing-rules4 key values as list

* nmcli: amended the routing-rules4 key values as list

* nmcli: amended the routing-rules4 key values as list

* test_nmcli: amended whitespaces

* Update 3401-nmcli-needs-type.yml

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-29 06:49:49 +02:00
Frank Dornheim
ef07f9b9ff
Enable deprecaded message for ignore_volatile_options (#3429)
* enable deprecate message for ignore_volatile_options

* fix E128

* add frament 3429

* remove default value and modify the resulting checks
spelling fixes
bump version for deprecated messge

* fix spelling and depricated version

Co-authored-by: Frank Dornheim <“dornheim@posteo.de@users.noreply.github.com”>
2021-09-28 07:07:55 +02:00
Chris Frage
1bb2ff5128
Fix require_two_factor_authentication can't be null (#3453)
* fix: require_two_factor_authentication default=false

* chore: add changelog fragment

* docs: require_two_factor_authentication default value

* fix: don't send require_two_factor_authentication null value

* chore: fix changelog
2021-09-27 21:50:21 +02:00
Frederic Werner
ba2917a7dc
chore: add deprecation warning for gitlab group membership (#3451)
* chore: add deprecation warning

* chore: add deprecation message, version and collection

* chore: add changelog fragment

* docs: add deprecation info

* fix: max line length and whitespace

* fix continuation line under-indented

* Update changelogs/fragments/3451-gitlab-group-member-deprecate-name-and-path.yml

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

* Update plugins/modules/source_control/gitlab/gitlab_group_members.py

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-27 21:49:52 +02:00
Chris Frage
b6b7601615
Fix: GitLab API searches always return first found match (#3400)
* fix: return correct group id
match only full_path or name

* chore: add changelog fragment

* fix: indentation multiple of four

* refactor: use two loops

* fix: typo of group id

* fix: changelog fragment
2021-09-26 18:59:39 +02:00
Ricardo Sanchez
43a9f09a17
open-iscsi: adding mutual authentication support and updating authentication parameters description (#3422)
* Adding mutual athentication support and changing doucumentation about authentication credentials

* Removing blank line with whitspaces

* Update plugins/modules/system/open_iscsi.py

Adding version_added to node_user_in parameter

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

* Update plugins/modules/system/open_iscsi.py

adding version_added attibute to new parameter password_in

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

* Update plugins/modules/system/open_iscsi.py

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

* Adding changelog fragment for #3422

* Rename 3422-open-iscsi-mutual-authentication-support.yam to 3422-open-iscsi-mutual-authentication-support.yaml

* Update changelogs/fragments/3422-open-iscsi-mutual-authentication-support.yaml

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

* Update changelogs/fragments/3422-open-iscsi-mutual-authentication-support.yaml

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

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-09-26 13:38:17 +02:00
Gaetan2907
147ca2fe66
Keycloak: Fix bug on keycloak_authentication, requirement not always updated (#3330)
* Fix diff mode when updating authentication flow with keycloak_authentication module

* Update documentation of create_or_update_executions function (return tuple instead of dict)

* Fix: Update requirement when new exex created

* Add changelog fragment

* Update changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml

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

* Update changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml

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

* Edit requirement of sublow

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-26 13:30:29 +02:00
Hartwig Hauschild
ae6cbc2d82
mail: adding capability to specify ehlo hostname (#3425)
* Adding capability to specify ehlo hostname

* Fixing default for ehlohost

the CI did not like "None" as default in the documentation,
judging from the rest of the definitions omitting that seems to be right

* Update plugins/modules/notification/mail.py

Proper spelling in documentation

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

* Adding Changelog Fragment

* Update changelogs/fragments/3425-mail_add_configurable_ehlo_hostname.yml

Proper phrasing in changelog

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

* integration-test for ehlohost parameter

* proper description, increased async-time

changed body of ehlohost-mail to reflect ehlohost
increased async from 30 to 45 as CI failed because
smtp was already down.

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-09-24 05:30:14 +00:00
Frank Dornheim
8e7d49c1c6
lxd_container: do not ignore volatile configs by option (#3331)
* do not ignore volatile - fix #2466

* remove unnecessary checks

* fix ansible-tests sanity

* fix access to the option: ignore_volatile_options

* add fragment

* fix quotation marks error

* fix review findings

* fix sanity error

* fix description - in yaml examples use true not True
comment out the deprecate message

* remove "default=True" at ignore_volatile_options
fix spelling

* fix sanity error that ignore_volatile_options have no default value

* undo changes. add defaut value and remove keyword at dict.get()

* fix sanity error

* small spelling fixes

* change text for fragment

* Fix description sentence.

Co-authored-by: Frank Dornheim <“dornheim@posteo.de@users.noreply.github.com”>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-20 20:31:26 +02:00
Alexei Znamensky
2ad7ed4f83
kernel_blacklist - revamped the module (#3329)
* kernel_blacklist - revamped the module

* file default and setting "lines" when file does not exist

* added changelog fragment

* added change in arg_spec to the documentation block

* Update plugins/modules/system/kernel_blacklist.py

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

* Update plugins/modules/system/kernel_blacklist.py

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

* Update plugins/modules/system/kernel_blacklist.py

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

* fixed: initialize self.pattern before self.var.is_blacklisted

* File writing recoded

* added try/finally for the file

* multiple changes:

- fixed case when last line of the existing file has no newline char
- added integration tests

* PR: integration test now using remote_tmp_dir

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-20 19:39:35 +02:00
Matthew Martin
02d0e3d286
openbsd_pkg: Fix KeyError (#3336)
If package installation has an error after the package is install (e.g.
when running tags), then there will be output on stderr and the fallback
regex will match; however, since pkg_add exited non-zero, changed is
never added as a key to the dictionary. As a result the code at the end
of main that checks if anything has changed raises a KeyError.
2021-09-20 19:19:04 +02:00
Chris Frage
9ce1009643
Add require_two_factor_authentication property to gitlab group (#3367)
* feat: add require_two_factor_authentication property

* chore: add changelog fragment

* chore: add gitlab_group test tasks

* chore: add gitlab tests

* chore: add gitlab group tests

* docs: apply suggestions

* fix: removing default value
2021-09-20 06:55:43 +02:00
Chris Frage
e48f9fdf74
Add gitlab_project CI/CD properties (#3379)
* feat: add ci_config_path property

* feat: add shared_runners_enabled property

* chore: add changelog fragment

* docs: add missing dot

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

* docs: ci_config_path change description

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-09-20 06:54:43 +02:00
Alexei Znamensky
7aae8d5386
Interfaces_file - improvements (#3328)
* pythonific!! no camel cases, bitte

* simplified iface attributes parsing

* some improvements, passing tests

* simplified set_interface_option()

* further simplifications

* remove unreachable stmt

* pythonified a file open

* added changelog fragment

* adjustment per PR

* PR: fixed the auto- case

* PR: added testcase and chglog frag for the misleading change report

* extra line removed

* integration is not destructive
2021-09-19 13:44:37 +02:00
Max Bidlingmaier
7a2efb4775
Get behavior of gitlab_project_members to the one of gitlab_group_members (#3319)
* Initial change to get behaviour of gitlab_project_members like the new gitlab_group_members

* added changelog

* linter: removed trainling whitespaces

* Update plugins/modules/source_control/gitlab/gitlab_project_members.py

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

* Update plugins/modules/source_control/gitlab/gitlab_project_members.py

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

* Update plugins/modules/source_control/gitlab/gitlab_project_members.py

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

* Update plugins/modules/source_control/gitlab/gitlab_project_members.py

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

* Update plugins/modules/source_control/gitlab/gitlab_project_members.py

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

* requested changes

* linter fixes

* undoing formatting changes to existing code

Co-authored-by: Max-Florian Bidlingmaier <Max.Bidlingmaier@konsolan.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Max Bidlingmaier <Max-Florian.Bidlingmaier@sap.com>
2021-09-16 22:26:31 +02:00
Patrick Pfurtscheller
331f5bdf24
redfish_utils: adding "Id" to the add user function (#3343)
* Adding "Id" to the add user function

Some implementations of Redfish (e.g. the one in Cisco's CIMC) seem to require the id of the new user for account creation.
I'm not that firm with Python but lines 982 and 983 should fix it.

* changed indention

* created changelog fragment

* Update changelogs/fragments/3343-redfish_utils-addUser-userId.yml

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

* Update change type

* supplemented the description of the ID parameter

* Update plugins/modules/remote_management/redfish/redfish_command.py

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-16 22:20:49 +02:00
Martin Vician
dc8d076a25
tss: add option for token authorization (#3327)
* Added token parameter for AccessTokenAuthorizer

Parameters username and password are not required anymore because of
this.

* Added changelog fragments

* Apply suggestions from code review

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

* token authorizer is prioritized

token authorizer is prioritized when token parameter is set

* Apply suggestions from code review

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

* domain optional if token not provided

* Updated examples

- `base_url` is required everywhere
- examples for user, name + domain authorization included
- token authorization included

* Update 3327-tss-token-authorization.yml

* Apply suggestions from code review

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

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-14 13:34:59 +02:00
Ajpantuso
118c040879
pids - refactor module to make version-based behavior consistent (#3315)
* Initial commit

* Adding changelog fragment

* Further refactoring

* Fixing bad copy/paste and adding task for psutil >= 5.7.0 install

* Inverting psutil installation order to reduce duplication

* Optimizing regex compilation
2021-09-13 07:16:49 +02:00
Raphaël Droz
0a5db85ad5
gitlab_runner: Support project-scoped runners registration (#2971)
* support project-scoped gitlab.com runners registration

* rename glproject variable to gitlab_project

* update version

* Update plugins/modules/source_control/gitlab/gitlab_runner.py

Co-authored-by: Raphaël Droz <raphael.droz+floss@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-09-13 07:16:06 +02:00