Commit Graph

3183 Commits (d35bef68f5d5502d3718d7b9a260308686c1c981)

Author SHA1 Message Date
maulikd 9558f53a58
Fix git submodules path issue (#75655)
* Fix git path used for submodules

* Fix git submodules integration test
3 years ago
hyperreality c3fc8fb99a
apt module: add option to allow package downgrades (#74852)
* apt module: add option to allow package downgrades

* Add new option to module so users don't have to force downgrades which
  is insecure and dangerous

* Add integration tests similar to upgrade integration tests

* Changelog

* Update changelog fragment

* Update changelogs/fragments/74852-apt-allow-downgrade.yaml

Co-authored-by: Amin Vakil <info@aminvakil.com>

* Update lib/ansible/modules/apt.py

Co-authored-by: Amin Vakil <info@aminvakil.com>

* Update lib/ansible/modules/apt.py

Co-authored-by: Amin Vakil <info@aminvakil.com>

Co-authored-by: Amin Vakil <info@aminvakil.com>
3 years ago
Brian Coca 3d83c325dd
Fix metadump (#75668)
* ensure dump produces json

* clog and tests

* remove library additions since they are not usable

* avoid any/all dirs

* ensure we dont use local dir as playbookdir
3 years ago
Sloane Hertel 469b559ebe
Try all galaxy servers when locating available versions for a collection (#75468)
* If an exception occurs when getting a collection's metadata, continue to the next in the server list.

* Warn for unknown exceptions when finding versions of a collection

* Test that an invalid server is no longer fatal if a subsequent server has the collection

* Fix server for verify tests - compare checksums against the server from which it was installed

* Add tests for verify and fix that code path to mirror install/download behavior for server errors

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
3 years ago
devon-mar 3e7a622204
Fix unexpected exception when a role has an empty argument_specs.yml (#75604)
* Fix role with empty argument_specs.yml

* Use try/except and add changelog fragment

* Always return a dict

* Add test for empty argument_specs key
3 years ago
Abhijeet Kasurde 12734fa21c
yaml dumper: Add YAML respresenter for AnsibleUndefined (#75078)
Fixes: #75072

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Matt Clay de01db08d0
pip - Use pip from the current Python interpreter. (#75634)
* pip - Use pip from the current Python interpreter.

If `executable` and `virtualenv` were not specified, and
the `pip` Python module is available for the current interpreter,
use that `pip` module instead of searching for a `pip` command.

* Add comment about needing `__main__` to run `pip`.

* Fix unit test.

* Add porting guide entry.

* Update changelog to match porting guide description.

ci_complete
3 years ago
Matt Clay fc8197e326
AnsiballZ - Make sure cwd is accessible. (#75636) 3 years ago
Sloane Hertel f38a97cece
Fix build_ignore when installing a collection from source (#75547)
* Make individual dirs that should exist instead of using shutil.copytree

* Test build_ignore when installing collections in git repos

* changelog

* Fix assertion
Fix git directory

* Fix nested content while building the collection dir

Test installing a collection from a git repo and artifact have the same result

Refactor to use variables
3 years ago
Mads Jensen d6dededab8
Use context manager for file handling in some system modules. (#65227) 3 years ago
Martin Krizek 9c2f44b884
Fix templating task action with host-specific vars (#75600)
Fixes #75568
3 years ago
Brian Coca 2462ec74a0
validate_args_spec, use combine vars and in precedence (#75471)
* combine vars and in correct precedence
* add examples
3 years ago
Sloane Hertel e5f6c2d141
Fix rekey_on_member when key is undefined (#75131)
* Fix rekey_on_member when key is undefined and add a test case

* Add documentation about error handling in filter and test plugin sections
3 years ago
Brian Coca bbf5bbd8e4
removing out of date example ansible.cfg (#75193)
removing  out of date example ansible.cfg, show user how to generate from ansible-config

Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
3 years ago
Sloane Hertel db3e8f2c1c
import_role - support templating _from_files with --extra-vars (#75269)
* Support templating _from_files with --extra-vars for imported roles

* Add tests for templating the filenames for import_role, import_playbook, and import_tasks

* Add documentation

Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
Co-authored-by: Martin Krizek <martin.krizek@gmail.com>
3 years ago
Martin Krizek d36116ef1c
dnf: ensure we use the correct locale for dnf API (#75264)
Fixes #75021
3 years ago
Matt Martz 74f5367673
Ensure `heuristic_log_sanitize` returns correct data if no password found (#75570)
* Ensure heuristic_log_sanitize returns correct data if no password found. See #75542

* Need to allow code to flow through
3 years ago
Pilou 3d7f2a1366
Fix an exception when passlib library is used with a wrapped algo (#75527)
* Test a passlib wrapped algo with a password lookup

* Fix error when passlib is used with a wrapped algo

The exception was:

     An unhandled exception occurred while running the lookup plugin 'password'.
     Error was a <class 'TypeError'>, original message: issubclass() arg 1 must be a class

and can be reproduced using the following command:

    ansible localhost -i localhost, -mdebug -amsg="{{ lookup('password', '/dev/null encrypt=ldap_sha512_crypt') }}"

The concerned algo are: bsd_nthash, django_argon2, django_bcrypt, ldap_bcrypt,
ldap_bsdi_crypt, ldap_des_crypt, ldap_hex_md5, ldap_hex_sha1, ldap_md5_crypt,
ldap_pbkdf2_sha1, ldap_pbkdf2_sha256, ldap_pbkdf2_sha512, ldap_sha1_crypt,
ldap_sha256_crypt, ldap_sha512_crypt, roundup_plaintext
3 years ago
Toshio Kuratomi b37a0630da
Revert "use versioned doclink for url references (#74245)" (#74782) 3 years ago
Martin Krizek 2ba9e35d09
yum: fix yumstate when wildcards are used in list arg (#75545)
Fixes #74557

* map is not available on centos 6's jinja...
3 years ago
Brian Coca 3ca50a2200
Clarify get_bin_path error message (#75544) 3 years ago
Brian Coca ff72908b4d
Fix --list-hosts when undefined var is used (#75533)
fixes #75354
3 years ago
Martin Krizek 51f2f1ac5e
yum: fix parsing of check-update with subsequent empty lines (#75452)
Rather than adding further complexity to the regex, preprocess the output to
remove any empty lines. Now the only purpose of the regex is to fix
wrapped lines.

Fixes #70949
3 years ago
Martin Krizek 9505f8c75d
dnf: allow for download_only to be run without root (#75532)
Fixes #75530
3 years ago
Brian Coca 91319c5cfc
Avoid accessing delegated vars when you dont have a host (#75524)
* avoid getting delegated vars w/o inventory host

 fixes #75512

 In the case of imports, we don't have a host, so getting host vars for
 the delegated host makes no sense and should be avoided.

* also avoid error on vars_files with per host vars

* test

* testing given case

* oops
3 years ago
Brian Coca b554aef3e1
More options for password passing (#73117)
* add 'file options' for become and connection pass
* implemented getting passwords from file or script
* added config entry
* fixed env var name and noted executable behaviuor

Co-authored-by: Rick Elrod <rick@elrod.me>
3 years ago
Brian Coca 214f0984a9
Dump keyword data (#75446)
* Add keywords to ansible-doc dump

  also fixed issue with async
3 years ago
Martin Krizek 1c34492413
dnf: align the return value of the list argument with yum (#75501)
* dnf: align the return value of the list argument with yum

Fixes #75483

* Add integration test
3 years ago
Matt Clay 99a79e1969
ansible-test - Move code from _data to _util. (#75495)
* Update paths to match relocated files.
* Update ansible-test symlink paths.
* Update path classification.
* Update MANIFEST.in
* Update sanity test context paths.
* Update sanity ignores.
* Update shebang sanity test.
* Update configure-remoting-ps1 sanity test.
* Update BOTMETA.yml to reflect new paths.
* Update paths in collection loader comments.
* Update Makefile for ansible-test.
* Update docs.
* Add changelog fragment.
3 years ago
HeroCC bc22f70a21
Add host information to the retry print statement (#75494)
* Add host information to the retry print statement

* Add changelog fragment reflecting retry print change
3 years ago
Brian Coca 7a9246a219
ansible-pull, restore repo options (#75491) 3 years ago
Martin Krizek 3ecf438e66
jinja2_native: short-circuit literal_eval for non-strings (#75484) 3 years ago
Martin Krizek a88741cf14
dnf: properly capture transaction error (#75444)
Fixes #72651
3 years ago
Brian Coca 03083c3139
setup module, dont truncate hpux interfaces (#75423)
* setup module, dont truncate hpux interfaces

  fixes #70533

 no hpux to test so relying on man page and users that reported successful testing
3 years ago
Hossein Zolfi 3d872fb5e8
Add new comment attribute to template plugin (#69253)
* Add new comment attribute to template plugin

Add comment_start_string and comment_end_string attribute to template
plugin


Co-authored-by: Hossein Zolfi <h.zolfi@inside.sahab.ir>
3 years ago
Matt Clay 2b463ef197
ansible-test - Upgrade pylint to 2.9.3. (#75480)
* ansible-test - Upgrade `pylint` to 2.9.3.
* Update pylint ignores due to rule name change.
* Disable pylint deprecated-class for compat code.
* Add pylint ignores for test support content.
* Add ignores for arguments-renamed in lib/ansible/
* Add pylint ignores for collection_loader.
* ansible-test - Ignore deprecations in legacy collection loader.
* ansible-test - Suppress pylint consider-using-with
* ansible-test - Suppress pylint false positive.
* ansible-test - Suppress pylint consider-using-with.
* ansible-test - Suppress pylint deprecated-module
* Disable some of the new pylint suggestions.
* Remove unnecessary six usage from string_format pylint plugin.
* Remove obsolete ignore entry.
3 years ago
Matt Clay 7450e87615
Fix up string splitting to prepare for pylint update. (#75479)
* Use rsplit with maxsplit in BaseCacheModule.
* Use maxsplit for accessing first item.
* ansible-test - More efficient splitting.
3 years ago
Matt Clay ce6d8a143c
Code cleanup to prepare for pylint update. (#75475)
* user - Remove unused code.
* Replace deprecated abstractproperty decorator.
* Fix __all__ to be a tuple.
* Use a generator in subelements lookup.
* Use from import in basic.py
* Add changelog fragment.
* Fix selinux unit test.
3 years ago
Sloane Hertel e24eb59de5
Improve ansible-galaxy error for InconsistentCandidate exception (#75235)
* Improve error for InconsistentCandidate exceptions

* Add test case for installing a collection with an inconsistent version

* Add test case for installing a collection that has a dependency with an inconsistent version

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
3 years ago
Sloane Hertel cea4886c7c
Update test container versions (#75447)
* Update test container versions to use the most recent which contain Python 3.10.0 RC1
3 years ago
Felix Fontein fae299708f
plugin attributes: make validate-modules strict again, improve version_added support (#74602)
* Add basic schema for attributes.

* Support attributes for version_added_collection adding mechanism.

* Add changelog fragment.

* Support new attribute properties from #74331.

* Require additional properties strictly.
3 years ago
Brian Coca 75e6bdb579
ensure we convert path in warning or py2.6 breaks (#75413) 3 years ago
Sloane Hertel b541a148d5
Fix dnf package matching (#75411)
* Fix a bug with the dnf module not using all components of a package name when filtering to determine if it's installed

* changelog

* Simplify splitting on the last '.'

* Update lib/ansible/modules/dnf.py
3 years ago
Felix Fontein b8ebf32d85
Add sanity tests which ensures that _info and _facts modules set supports_check_mode=True. (#75324) 3 years ago
Martin Krizek 5a38076568
Globals should be accessible when importing a template without the context (#75384)
Fixes #75371
3 years ago
Sam Doran fa7482c63a
Change interpreter discovery defaults to silently prefer Python 3 (#75049)
Push /usr/bin/python to almost the bottom of the barrel. This makes the strategy to prefer
specific versions of the "mystery meat" version.

* Change INTERPRETER_PYTHON default to 'auto'
    Change description to match change in behavior.
    Change deprecation message to a warning.

* Update docs
* Add porting guide entry
* Update unit tests
* Update integration test
* Allow INTERPRETER_PYTHON_FALLBACK to be configure using a variable
* Prefer platform-python above other Python 2 interpreters
* Add Python 3.10 to the list of interpreters
3 years ago
Brian Coca 8d41b97329
Skip python interpreter discovery for 'forced local' module execution (#74824)
mostly for use with network_os
  use 'remote is local' property as indicator
  ensure task_vars are as expected in test
3 years ago
Sam Doran 1d2af0b89e
ansible-test - allow for the same listening port on multiple interfaces (#75387) 3 years ago
Sloane Hertel c8d413164d
ignore/warn for undefined vars in unused handler names (#75244)
* Make undefined variables in handler names non-fatal if the handler is not used

* If the handler has no way to be notified (i.e. the name can't be templated and the handler has no listen topics), display a warning

* Add tests for variables in handler names

* changelog
3 years ago
Sam Doran d8dcfe737a
ansible-test - add ssh debugging logging (#75374) 3 years ago
Martin Krizek 58e38044fe
Fix when evaluation on Native Jinja and Python 3.10 (#75202)
* Fix when evaluation on Native Jinja and Python 3.10

* Add unit test

* Add explaining comment

* Enable jinja2_native before tests

Co-Authored-By: Matt Martz <matt@sivel.net>

* Sanity

* Return native template module instead of modifying globals

Co-authored-by: Matt Martz <matt@sivel.net>
3 years ago
Sloane Hertel 83039a38ad
ansible-test - add RHEL 8.4 as a remote (#75362) 3 years ago
Sloane Hertel f6b27f6e35
Update test container versions (#75359)
* Update test container versions for default-test-container and ansible-core-test-container
3 years ago
Felix Fontein 7726b70d9a
Improve handling of AnsibleModule arguments in validate-modules (#75332)
* Make sure AnsibleModule positional arguments are validated.

* Extract ANSIBLE_MODULE_CONSTURCTOR_ARGS with inspection.

* Remove no longer necessary return value.

* Fix PR #.

* argument_spec might not have been specified, as in community.general.xenserver_facts.

* Fix typo.
3 years ago
Sergey 40ca87a963
Add packaging to requirement of ansible-test (#75356)
* Add packaging to requirement of ansible-test

Fix #75353

After requires_ansible field was added as mandatory to runtime.yml
file, ansible-test fails to check this field if it doesn't have
packaging module.

[1] https://github.com/ansible/galaxy-importer/pull/124
3 years ago
Brian Coca 82bab063e7
service_facts, now more accurate on systemd (#75326)
* service_facts, now more accurate on systemd
3 years ago
Matt Martz 4dca539a29
Expose `unredirected_headers` to `uri` and `get_url` modules (#75308) 3 years ago
Martin Krizek 767b2f07b0
Ensure Jinja2 template header overrides are used (#75306)
Fixes #75275
3 years ago
Brian Coca e5a2fe4c41
fix ssh cli defaults (#75245)
* fix ssh cli defaults

  fixes #75221
3 years ago
Sloane Hertel 4d78b58540
Fix resolution of action/module names in module_defaults (#75284)
* Fix resolution of action/module names in module_defaults

* changelog

* Include legacy module_defaults entries for builtin plugins
3 years ago
Ashwini Mhatre d016499dcd
Update network user guide to point to ansible.utils.cli_parse module and add docs for validate plugin (#75104)
* Update network user guide to point to ansible.utils.cli_parse module as ansible.netcommon.cli_parse is deprecated from ansible.netcommon 2.0.0 release
3 years ago
Sam Doran 5dfa9bdd9f
Check if a string is possibly a template in `ansible.template.is_template` (#75092)
* Move is_possibly_template() to function
  Call is_possibly_template() from is_template() to avoid more expensive analysis if unnecessary.
3 years ago
Jordan Borean feed68f6f0
winrm - Add explicit env vars to pass into kinit (#75256)
* winrm - Add explicit env vars to pass into kinit

* Add ini entry and don't override existing env vars
3 years ago
Brian Coca 61900c7672
modules moved to use best_parsable_locale (#75250)
* modules moved to use best_parsable_locale

* fixed invocations

* better better

* also module_utils

* converted to function as per fb

* patch testt

* whitespace
3 years ago
James Spurin d527be8a52
set host_key_checking check to False, rather than if not (which captures False and None) (#75168)
* set host_key_checking check to False, rather than if not (which captures False and None)
* add host_key_checking default to ssh.py / update documentation
3 years ago
Sloane Hertel 3b861abce1
add action_groups support to collections (#74039)
* Canonicalize module_defaults actions and action_groups pre-fork and cache them on the play

* Call get_action_args_with_defaults with the resolved FQCN plugin and don't pass the redirect list

* Add validation for action_group metadata and a toggle to disable the warnings

* Handle groups recursively referring to each other

* Remove special-casing for non-fqcn actions in module_defaults groups

* Error for actions and groups in module_defaults that can't be resolved

* Error for fully templated module_defaults

* Add integration tests for action_groups

* Changelog
3 years ago
Abhijeet Kasurde e7a3715a90
recursive_diff: handle error when parameters are not dict (#74801)
Co-authored-by: Sam Doran <sdoran@redhat.com>
3 years ago
Martin Krizek 8ab418f41b
Disable jinja2_native warning in CI (#75214) 3 years ago
Felix Fontein 67bc49e001
Restrict packaging to < 21.0 for Python < 3.6. (#75186) 3 years ago
Sam Doran a8de35e131
task_executor - use correct value for ssh connection retries (#75155)
Since the task and connection both have the same 'retries' keyword, the task default
would override the connection value.

Do not pass 'retries' from the task to the connection options.

* Set ssh_connection retries default value back to 0
  It was 0 before the move to config and was changed to 3 by accident.
3 years ago
Brian Coca 363c1a3fba
Vaultfilters (#74998)
add vault and unvault filters

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Brian Coca 60c9f045cc
Unfrack extra vars (#75127)
* Ensure we keep teh original path as per cli

  fixes #75126

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Sam Doran 16a74b798c
module_common - handle cache directory creation collision (#75106)
* module_common - handle cache directory creation collision

Occasionally multiple workers can try to create the cache directory if it exists. Catch the exception
and handle it.

* Just re-raise if it doesn't exist rather than trying again

* Use exists_ok rather than handling an exception

* Remove unused import and unused variable

* Go back to try/except but with OSError

Since we do not have split controller remote, this needs to be able to run in Python 2 in order
to be merged currently.
3 years ago
Sloane Hertel 865bda3a11
Add a resolved_action task attribute (#74709)
* The resolved_action is the formatted version of the final plugin in the PluginLoadContext's redirect_list

* Collection plugins are represented as FQCN

* Legacy plugins are represented with only the plugin name

* Add tests

* Changelog
3 years ago
Toshio Kuratomi a4021977ad
Fix structure of generic snippet feature (#74932)
* Fix struture of cli/doc.py snippet code.

A couple releases ago, cli/doc.py was modified to mostly conform to the
data processing pipeline steps.  format_plugin_doc() was the biggest
exception in that refactor.  When the snippet code was made generic
instead of being only for modules, the new code should have conformed to
the data processing pipeline too.

* Move the decision to output a snippet to the run() method alongside
  the decision to output a listing versus plugin_docs.
* Move the test for invalid plugin_types to the run() method as it
  affects all snippets in this run, not just a single snippet. (-t can
  only be specified once)
* Rename get_snippet_text() to format_snippet() as:
  * This is the data formatting step
  * The format_snippet() name matches with its conceptual sibling,
    format_plugin_doc().
* Use ValueError inside of format_snippet() to flag unrecoverable errors
  formatting a single snippet.
* Emit a warning when format_snippet() raises ValueError and continue to
  the next snippet.
* If the yaml(?) or toml inventory plugin is specified for snippet output,
  raise ValueError() so that the user sees a warning instead of simply
  seeing blank output.
* Do not modify arguments passed into format_snippet().  This is the
  formatting step so data should not be modified.
* Change _do_yaml_snippet() and _do_lookup_snippet() to operate side
  effect free.
* Fix raising of exceptions when formatting requred options for snippets.

* Unrelated: Use to_text() instead of to_native when calling
  display.warning(). to_native() is used for raising exceptions.  Not
  for display methods.

* Add a changelog
3 years ago
Brian Coca 415e08c297
Try to get best usable locale (#75033)
specially for when you have parameters in unicode but need
  to scrape responses, C is still the fallback

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Brian Coca 50b6d28ee1
Config init+ (#74914)
Can now specify plugin/plugin type for list and dump actions
 New 'init' action to create usable config sources 

Co-authored-by: Felix Fontein <felix@fontein.de>
3 years ago
David Shrewsbury 703cb79442
Implement async callbacks (#74953)
* add changelog and output from default callback
* add test
* add comments about TE task
3 years ago
Sloane Hertel ca6123e0ee
Template suboptions in a role's arg spec (#75073) 3 years ago
Abhijeet Kasurde b0ae3f8a8d
test: Unit tests for validation methods (#75061)
* check_required_one_of()
* check_required_by()
* check_required_if()
* check_missing_parameters()

Fixes: #55994

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Nasser Alansari 6dbfd73174
YAML representer for VarsWithSources (#68525) 3 years ago
Junegunn Choi 8e755707b9
Add 'hash_behaviour' option to include_vars module (#72944) 3 years ago
Felix Fontein c404a9003f
ansible-doc: improve version_added handling (#73602)
* Output version_added on top level, and improve version_added formatting

* Handle 'historical' version_added.
3 years ago
Nathaniel Case ad203a7dbd
Add page describing terminal plugins to docsite (#75066) 3 years ago
Sam Doran cd473dfb2f
play - validate hosts entries (#74147)
* Change tests to pytest-style tests
* Add tests for invalid hosts
* Validate host inputs
  - check for empty values
  - check for None
  - check for values that are not a sequence and are not strings
  - add unit tests

* Move play name setting to get_name() and out of load()
* Add _validate_hosts() method
  By defining this method, it gets called automatically by FieldAttributeBase.validate().
3 years ago
Brian Coca e8ae7211da
deprecate FileLock (#75032)
Co-authored-by: flowerysong <junk+github@flowerysong.com>
3 years ago
Matt Clay ce17498ec5
blockinfile - Remove unused code for Ansible 1.x. (#75040) 3 years ago
Matt Clay 5e65d9834b
tempfile - Remove unnecessary conditional. (#75039)
Also add integration tests for 100% code coverage.
3 years ago
Sam Doran afe6eb574e
slurp - improve error code and test coverage (#75038)
* Improve the error handling code

Rather than multiple return paths, have a single return and set the message based
on the type of failure.

* Add another test for non-specific failures

* Reorganize tests so failure tests are in one tasks file

* Remove os.stat() call and add changelog
3 years ago
Sam Doran 4ab791d501
command - remove unreachable code and achieve full test coverage (#75036) 3 years ago
Sam Doran 4e608c02fb
Add changelog and porting guide for _remote_checksum() deprecation (#75035)
I forgot to add it with the PR that made the changes.
3 years ago
Gonéri Le Bouder 5b8fb4dcd3 ansible-test: exposes tiny_prefix variable
ansible-test aws provider now creates and exposes a new tiny_prefix
variable to provide a shorter prefix for the AWS tests.
3 years ago
Brian Coca 79a0799082
fix typo in host_group_vars config (#75012)
* no need to deprecate, not used directly

  it just documents the use of the setting in loader
3 years ago
Jordan Borean 58d8397771
psrp - cleanup command (#74985) 3 years ago
Felix Fontein 58450f041a
Do not show empty version_added_collection values in ansible-doc text output. (#74999) 3 years ago
Brian Coca 77e936bd50
async_status revert most changes, keep some fixes, undep module (#74931)
* revert most changes, keep some fixes, undep module

  too many corner cases, reverting major changes for controller
  side processing.
3 years ago
David Shrewsbury 97acb0f470
role argspec - tag role argspec validation task with 'always' (#74994)
* update tag docs
3 years ago
Brian Coca d2d45900ed
setup module, filter compensate for prefixes (#74924)
Allow user to abstract internal implementation from requested info
3 years ago
Jordan Borean cf3a304ce1
psrp - Fix reset connection on failed scenarios (#74967)
* psrp - Fix reset connection on failed scenarios

* Update psrp-reset.yml

* Update changelogs/fragments/psrp-reset.yml

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>

* Update changelogs/fragments/psrp-reset.yml

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Sam Doran a8cf0196f7
subversion - fix stack trace when getting repository information (#74405)
* subversion - set LC_ALL for accurate command output parsing

When LC_ALL is not set, the output language of commands will differ based on locale. There
is a lot of history of trying to fix this. See the following pull requests:

https://github.com/ansible/ansible-modules-core/pull/4358
https://github.com/ansible/ansible-modules-core/pull/4358

This patch attempts to fix this my setting LC_ALL to a UTF-8 locale. Setting LC_ALL to C reintroduces this bug https://github.com/ansible/ansible-modules-core/issues/4178.

I'm sure there are some problems I am not seeing with setting this to en_US.UTF-8, but that is
the only way I could find to fix this bug without reintriducing the bug mentioned above.

* Rather than setting locale, just check for matches before trying to get groups

This is a pragmatic solution to avoid the stack trace since setting the locale correctly
to ensure message parsing is accurate is problematic.

* Improve regexps for finding revision and URL
3 years ago
Sam Doran 9a21e24778
get_distribution - Return distribution for all platforms (#71641)
Since moving to distro, it is possible to return this information for all platforms, not just Linux.
Also return version information for all platfrom not just Linux.
Update unit tests.
Remove some duplicate unit tests though I think there are more to remove.

* Fix docstring formatting

* Minor docstring changes

* Mock distro.id for Solaris service test

* Update comment
3 years ago
Brian Coca 4c8c40fd3d
fix unsafe preservation across newlines (#74960)
* fix unsafe preservation across newlines

  CVE-2021-3583
  ensure we always have unsafe

Co-authored-by: Rick Elrod <rick@elrod.me>
3 years ago
Brian Coca 675df166c2
fix ssh_transfer_method/scp_if_ssh defaults (#74925)
* fix ssh_transfer_method/scp_if_ssh defaults

  fixes #74922

* clog
3 years ago
Jonathan Kirszling 50e998e303
apt_key: add --recv argument as last one (#74949)
* apt_key: add --recv argument as last one

* Add unit test

* Add the required boilerplate

Co-authored-by: Marius Gedminas <marius@gedmin.as>
3 years ago
David Shrewsbury 6539c59857
ansible-pull - update help info for --directory option (#74936)
* Update -d help info for ansible-pull

* fix pep8
3 years ago
Martin Krizek 5ac1b04929
Add support for unicode in ansible-inventory CLI (#74912)
* Add support for unicode in ansible-inventory CLI

Fixes #57378

* Add tests

* First test fix

* --output tests

* fix
3 years ago
Sam Doran 0a5cc80ce2
slurp - handle error when path is a directory (#74930) 3 years ago
Brian Coca 1c4ca154fa
improve inv plugin selectino for snippets (#74933)
* improve inv plugin selectino for snippets
* add warning on no snippet for inventory
3 years ago
Brian Coca 6d2398db28
expand doc snippets to lookups and other plugins (#74403)
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Toshio Kuratomi <a.badger@gmail.com>
3 years ago
Sam Doran 004c33d9c5
unarchive - do not fail in init when trying to find required binary (#74892)
Test for the required binaries in the can_handle_archive() method and fail there. This
prevents failures for missing binaries unrelated to the archive type.

* Update missing zip binary message to match tar message
* Update unit tests
* Add integration tests
* Define packages based on the system rather than ignoring failures
3 years ago
Brian Coca 5dd8dc8fd0
minor service_mgr facts fixes (#74894)
* minor service_mgr facts fixes

  handle case in which ps command fails or returns empty
  updated tests since it now does keep trying to detect after ps fails
3 years ago
Brian Coca 6840b79e56
bring back async_status module for direct callers
also, deprecate it, they should use action instead
Co-authored-by: Felix Fontein <felix@fontein.de>
3 years ago
s-hamann e2658801f6
Add seed parameter to password lookup (#69775) 3 years ago
Matt Martz ffa548503d
Wrap all results, regardless of register, except for actions with clean facts (#73161)
* Wrap all results, regardless of register, except for actions with clean facts. Fixes #21088

* ci_complete

* Add tests

* Add clog frag
3 years ago
Hideki Saito e70fc88656
slurp - better error handling for unreadable files and directories (#68608) 3 years ago
Brian Coca 26827f5039
ansible-doc fix displaying 'CLI' options for plugin docs
cli options will now display either use provided info, or automating from the name


Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
3 years ago
Brian Coca 6a883f1cd6
better message and timeout warning when timeout (#74885)
* better message and timeout warning when timeout
3 years ago
Martin Krizek 4f3ee4624e
Add end_batch meta task (#74899)
* Add end_batch meta task

* Add note

* Fix sanity
3 years ago
Matt Martz ac77911491
Prevent conditional templating errors from masking task output. Fixes #37187 (#74891) 3 years ago
Abhijeet Kasurde 8f82e6327f
ansible-cli: Remove unnessary trailing space (#74880)
Fixes: #74875

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Matt Martz 840825b79c
Allow omit to work with include_role from_args (#74879)
* Allow omit to work with include_role from_args. Fixes #66349

* Add clog frag
3 years ago
Johannes Heimansberg b023f34f4a
service_mgr: Detect using symlink if proc/1 and ps fail
* runit and other alternative service managers tend to work via symlink so this covers most of em
* Fixes #74866.
3 years ago
Brian Coca 9c718ccc42
Async status rewrite
-  remove need for module (at least for posix side)
  - adds retry with backoff on fetching file, since
    race is bigger since we don't spend time on module
  - now gives more info on fail
  - also made actionfail/skip handle results if given
3 years ago
Martin Krizek e201b542be
Ensure end_play ends play, not batch (#74332)
* Ensure end_play ends play, not batch

Fixes #73971

ci_complete

* Preserve result

* Move AnsibleEndPlay to TQM

* Add tests

* Add changelog

* Explaining comment

* Fix changelog name

* ci_complete
3 years ago
Abhijeet Kasurde be9f8c69d1
unarchive: Fail when zipinfo is not available (#74632)
Fixes: #39029

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
David Lee Whiteside 805799ac8b
add pkcs11 support to Ansible ssh connection module (#32829)
* rebased with upstream

* removed extra usetty as it wasnt needed, style changes, added var option setable by inventory for pkcs11

* update pkcs11_provider version_added

* Update lib/ansible/plugins/connection/ssh.py

Co-authored-by: Jordan Borean <jborean93@gmail.com>

* Update lib/ansible/plugins/connection/ssh.py

Correct logic for a password being required for pkcs11_provider

Co-authored-by: Jordan Borean <jborean93@gmail.com>

* style nit fixes for checking pkcs11_provider is set

* fixed duplication when using password_prompt with pkcs11_provider

* added changelog fragment

* added changelog fragment

Co-authored-by: David Whiteside <david.whiteside@nrel.gov>
Co-authored-by: Matt Davis <nitzmahone@users.noreply.github.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
3 years ago
Jaroslav Mracek d9183b8df5
dnf - replace usage of private attribute with supported API (#73529)
base._update_security_filters is a private attribute of DNF used
as performance optimization. Modification or even call from outside
of DNF is against all recommendation including PEP8.

* Improve compatibility with all DNF versions

* Add changelog fragment for dnf security change
3 years ago
Brian Coca ba2b1a6bf6
fact gathering, ensure we get some linux hardware info even if some fails/times out (#74714)
* Add resiliency to linux hw fact gathering

 Now traps unexpected exceptions on mounts and continues
 gathiering other info.
 Also gives more info on why mount info gathering failed.
 more info if debugging
3 years ago
Matt Clay adc9e4a023 Updated ansible-test azure plugin help message. 3 years ago
Martin Krizek 01ab6c6ec7
Apply display_failed_stderr on loop item results (#74865) 3 years ago
Abhijeet Kasurde b0dcf0d164
collection: match skip message as per role install (#74861) 3 years ago
Therry van Neerven 35a2345809
Fixed typo in yum package (#72964)
* yum: Fixed typo in failure message: nevra --> envra
* Added changelog fragment
3 years ago
Rukmangathan e0558ac193
yum action plugin: 'use' as an alias of 'use_backend' (#70792)
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: rukmangathan <rukmangathan.annadurai@gigamon.com>
3 years ago
Sloane Hertel 5640093f1c
Use the module redirect_list when getting defaults for action plugins (#73864)
* Fix module-specific defaults in the gather_facts, package, and service action plugins.

* Handle ansible.legacy actions better in get_action_args_with_defaults

* Add tests for each action plugin

* Changelog

Fixes #72918
3 years ago
Brian Coca a5a13246ce
ssh remove unused/unusable cli option ssh_args (#74846) 3 years ago
Boris Korzun 99a983c92c
config: small typo fix (#74845) 3 years ago
Abhijeet Kasurde 148d4f6248
hostname: Add support for RedOS (#74844)
Fixes: #74779

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
geliwei 138b3b6851
hostname: add support for Anolis distro (#74829)
project website https://openanolis.org/

Signed-off-by: Liwei Ge <geliwei@openanolis.org>
3 years ago
Rick Elrod 2ad10ffe43 hostname: Make strategies consistent, drop py2.4
Change:
- Make strategies behave consistently and return the empty string
  instead of "UNKNOWN" (or "temporarystub") for the "before" value if
  the permanent hostname file does not exist or could not be read.
- Switch to `with open()` instead of annoying exception handling code
  (which was wrong and leaked file handles in several places). This
  drops Python 2.4 support for this module.
- Updated porting guide since users could be relying on these former,
  inconsistent values.

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Rick Elrod 8a0abed1ba [hostname] don't write in get_*() methods
Change:
- Hostname strategies' get_*() methods should never write to the
  filesystem. They are used in check_mode by default to determine if
  there is any work to be done.

Test Plan:
- New unit tests to ensure that (at least when in check_mode) the get
  methods don't ever call write.

Tickets:
- Fixes #66432

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Abhijeet Kasurde ae50d05182
ini: Add parameter to allow no value (#74806)
ConfigParser allows to read key with no value.

Fixes: #50594

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Matt Clay 397d3763ea ansible-test - Do not downgrade cryptography. 3 years ago
Matt Martz 98138584b7
Don't mutate os.environ in AnsibleModule.run_command, make a copy, and pass to Popen (#74791)
* Don't mutate os.environ in AnsibleModule.run_command, make a copy, and pass to Popen. Fixes #74783

* Simplify code a bit

* More simple

* Address some other potentially non threadsafe operations

* Add if around umask

* Address unit test assumptions

* Add clog frag

* yaml syntax issue
3 years ago
Matt Martz df5ce3e672
Remove deprecated cache support from script inventory plugin (#74813) 3 years ago
Matt Martz d27ce4cef3
Remove deprecated features from ansible.playbook.helpers (#74809)
* Remove deprecated features from ansible.playbook.helpers. Fixes #74135
3 years ago
Abhijeet Kasurde 27f61db86b
service: Document internal working of the module (#74726)
service module acts as proxy module for all service manager modules,
just like `package` module.
This is helpful in heterogeneous environments to manage services.

Fixes: #74507

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Matt Martz 4a4ffbadc5
Remove deprecated PlayContext.make_become_cmd (#74790) 3 years ago
Abhijeet Kasurde 52430d4228
dnf - fix whatprovides API block (#74764)
* Added additional query block
3 years ago
Abhijeet Kasurde 1bd7dcf339
encrypt: add new paramter 'ident' (#74595)
Add a new parameter `ident` for specifying version of BCrypt
algorithm. This parameter is only valid for `blowfish` hash type.
3 years ago
Matt Martz bc48eba896
Remove deprecated include vartags usage (#74780)
* Add clog frag
* Remove ignore
3 years ago
Sam Doran 71e33d2578
version test - improve message when value is empty (#74754)
When an empty value is provided, no `version` attribute will exist on the `LooseVersion` or
`StrictVersion` object. We catch and handle this, but it's not immediatebly clear that an
AttributeError means an empty value was provided.

Specifically handle the case where value or version are empty and add more
helpful error messages.

Add integration tests.
3 years ago
Alex Haydock 724a0c867e
Fix mistaken detection of atomic_container when rpm-ostree is present (fixes #74578) (#74579)
* Lower the priority of the atomic_container detection now that we have #73445 merged

* Add changelog fragment
3 years ago
Brian Coca d2d1f01f9d
avoid literal quoting in config lists (#74740)
* added tests
3 years ago
Sam Doran c0cb353ce1
Remove PyCrypto (#74699)
* Remove PyCrypto from setup.py and packaging script
* Remove mention of pycrpto from installation docs
* Remove PyCrypto from vault
* Remove pycryto constraint and unit test requirement
* Remove PyCrypto tests from unit tests
* Add docs and fix warning message
* Remove section about cryptography library in Ansible Vault docs
3 years ago
Sloane Hertel 9cfedcd9c9
Add changelog for ansible-galaxy improvements (#74738)
Changelog for #74240
3 years ago
Matt Clay ce04056797 Expand delegation options for coverage commands. 3 years ago
Jordan Borean e875e91363
ansible-test - use pwsh to generate stubs (#74271) 3 years ago
Sam Doran d8e6f21d9f
ini lookup - add case sensitive option (#74630)
* Add tests for case-sensitive option
* Run all test playbooks from a single file
3 years ago
Brian Coca 173d0a8de7
Skip interpreter discovery for network OSs(#74012)
skip python interpreter discovery on network os being set as this indicates a 'forced local' module and should use sys.executable.
3 years ago
David Shrewsbury 51b5659598
replace - better handling of file exceptions (#74686) 3 years ago
Brian Coca 35281e54d9
fix config to match doc split (#74665) 3 years ago
elara-leitstellentechnik c6ac9de67b
Do not remove non-empty cron tabs (#74497)
* Only remove crontabs if they are empty

* Add integration test to ensure system cron tab doesn't get removed. Increase cron integration tests separation.
* Also detect crontab which only contains whitespace as empty.
* cron integration test: Adjust system crontab path to be distribution specific.

Co-authored-by: Fabian Klemp <fabian.klemp@elara-gmbh.de>
3 years ago
Mark Mercado 1906d75907
Adding DigitalOcean cloud support to ansible-test (#74222) 3 years ago
Matt Martz d6e28e6859
Update vendored copy of `six` to 1.16.0 (#74680)
* Update to six 1.16.0

* Address linting issues

* Remove six find_spex/exec_module warning filters

* Remove unnecessary comment about Py2.6, 2.13 will not support Py2.6, and we're bumping this for 2.12

* ci_complete

* Add changelog fragment
3 years ago
Sam Doran 0affe4d027
ini lookup - catch and handle duplicate key and missing section errors (#74629)
* Remove unused import
* Add integration tests for errors
* Cleanup formatting on existing tests
* Add changelog
3 years ago
Sam Doran f99d024851
CI and compat fixes for Jinja2 >= 3.0 (#74666)
* Add constraint for MarkupSafe

MarkupSafe >= 2.0.0 requires Python >= 3.6.0. Add a constraint for older Python versions
and fix the `groupby_filter` test.

* Fix template_jinja2_latest test.

* patch filter decorators on newer Jinja2

* Jinja2 >= 3.0 renames several filter decorators used by Ansible itself, as well as by filters in collections. This patch ensures that the old names are usable within Ansible and by collections without warnings or errors.

* Ignore docs-build issues.

Co-authored-by: Matt Clay <matt@mystile.com>
Co-authored-by: Matt Davis <mrd@redhat.com>
3 years ago
Abhijeet Kasurde 1006363589
basic: Skip over module parameters (#74559)
While logging, journal.send accepts module parameters.
If module parameters similar to arguments in journal.send,
rename the parameter names before sending to journal.send

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Brian Coca 2c93b22043
use self.host which will always be updated (#74574)
* use self.host which will always be updated

  pc remote_addr is not correctly updated in all cases
3 years ago
Matt Martz 8d1cf7f266
Vendor `distutils.version` (#74644)
* Vendor distutils.version

* Fix import order. ci_complete

* remove distutils warning filter

* Don't remove warnings filter from importer

* ci_complete

* Add pylint config for preventing distutils.version

* Add changelog fragment
3 years ago
Brian Coca ddaa539ab1
Better handling of rstisms in ansible-doc (#74596)
* Better handling of rstisms

  replace tags more intelligently to make things more readable
  unit tests + minor adjustments
3 years ago
Sloane Hertel cf11c38caf
Exclude unreachable hosts in ansible_play_batch between plays (#74625)
ci_complete
3 years ago
Shane St Savage df6554c4ec
fix: action _fixup_perms2 macos +a remote_paths in list() as it can be a tuple (#74613)
* fix: action _fixup_perms2 macos +a remote_paths in list() as it can be tuple

in `lib/ansible/plugin/action/__init__.py`'s `_fixup_perms2`,
`remote_paths` can be a list or tuple. however, the macos
specific attempt to use chmod +a attempts to concatenate
`remote_paths` with a list, which will fail if it is a tuple.
wrapping `remote_paths` in `list()` fixes this error.

* Update changelogs/fragments/74613-actionfixup_perms2_macos_remote_paths_ensure_list.yml

Co-authored-by: Rick Elrod <rick@elrod.me>
3 years ago
David Shrewsbury 8fb54885bf
Role argspec: allow new argument spec file (#74582)
* support separate role argspec file in ansible-doc

* support separate role argspec file in ansible-core

* support both .yml and .yaml extensions on argspec file in ansible-doc

* fix filename building bug and rename some argspec files to test variations

* use yaml extensions from constants

* add superfluous meta/main.yml files to tests

* Update lib/ansible/cli/doc.py

Co-authored-by: Sam Doran <sdoran@redhat.com>

* update docs

* ci_complete

* add changelog and allow for main.yml variations

* add collection role testing

Co-authored-by: Sam Doran <sdoran@redhat.com>
3 years ago
Matt Clay 7b0c4845d9 Remove PyYAML warning filter in import test.
The filter is obsolete now that PyYAML imports go through our compat layer.
3 years ago
Brian Coca 7f7d3067e3
adhoc clarify help (#74616)
also added comments to code
3 years ago
Matt Clay 51fd05e76b Add support for testing with Python 3.10. 3 years ago
Ruediger Pluem 2f7e0b8489
user - consistently create user home directory on Linux (#71952)
Always use create_homedir when we are asked to create a home directory
in the User class. Don't use the -m and -k parameters from
useradd / luseradd as they behave differently with respect to
preexisting home directories. Instead always specify -M to ensure
that useradd / luseradd do not try to create the home directory.

This does not change potential different behaviours in child classes
of the User class.

Consider the new umask option from #73821 in create_homedir as well as
we do not let luseradd / useradd create the home directory any longer.
3 years ago
René Moser 403a5d147d
modules: get_url: Fix checksum binary validation (#74502)
From the sha512sum man page:

... The default mode is to print a line with checksum, a character indicating type ('*' for binary, ' ' for text), and name for each FILE.
3 years ago
Abhijeet Kasurde 4d7dc15d4e
service - compare version without LooseVersion (#74508)
The distutils module is not shipped with SUNWPython on Solaris.
It's in the SUNWPython-devel package. Do not use LooseVersion.

Fixes: #74488

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Jordan Borean a277644301
Add python 3.10 constraint for pyspnego (#74612) 3 years ago
Matt Clay e6d7aecbe4
Reorganize more ansible-test code. (#74611)
* Split out shell command.
* Relocate ansible-test integration code.
3 years ago
Matt Clay 065fc3ca17 Remove check for legacy core and extras dirs. 3 years ago
Matt Clay 5487e9e4fd Update runtime-metadata sanity test for Python 3.10. 3 years ago
Brian Coca 8cccabf1eb
cron: removal of deprecations and minor fix (#73591)
* removal of deprecations and minor fix

  name or cron_file is required.
  reboot was removed.
  updated docs to clarify usage.
  now using cron_file=/etc/crontab is an error

  fixes #37355
3 years ago
Matt Clay cbac26e500 Update import sanity test for Python 3.10. 3 years ago
Matt Clay 2c3a3bdd9c Update pylint sanity test to work on Python 3.10. 3 years ago
Matt Clay c2e15f45a6 Update ansible-test compile sanity test.
The test has been rewritten to improve error handling and add support for Python 3.10.
3 years ago
Brian Coca 35ff4ea95b
warn on walking through pathing issues (#74514)
* warn show pathing issues when wallking through provided paths

  moved issues from msg to actual warnings AND a specific return field

  fixes #25314

Co-authored-by: Sam Doran <sdoran@redhat.com>
3 years ago
Sam Doran 55b401a3e7
pause - ensure control characters are always set appropriately (#74568)
* pause - ensure control characters are always set appropriately

On some systems, curses.tigetstr() returns None, which does not work as a control character.

* Add unit tests

* Sort imports

* Skip on older Python

This is an action plugin and only runs on the controller, so no need to test of Python 2. Making
the import hackery work on Python 2 would required some more work which I am not sure is
worth it since we are moving away from Python 2 support on the controller.

* Make the tests work on Python 2 and 3
3 years ago
Matt Clay 07fb6f7547 Fix imports for the previous commit.
Also add a changelog entry.
3 years ago
Matt Clay 5dfc7ee078 Remove Shippable CI provider from ansible-test. 3 years ago
Matt Clay df2ae06d46 Fix ansible-test imports and paths after refactor.
Also include a changelog entry covering this commit and the previous.
3 years ago
Abhijeet Kasurde 38dd49eb00
ansible-inventory: Handle exception in toml parsing (#74486)
Handle stacktrace raise while parsing inventory in toml format

Fixes: #74404

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Miro Hrončok 728b52a6ff
Use /usr/bin/python3 on rhelish 9+ (#74547)
The /usr/libexec/platform-python symbolic link is just a backwards compatibility shim there.

See ce226d00fa
3 years ago
Abhijeet Kasurde 4627c30b2e
interpreter_discovery: Hide warning in auto_silent (#74509)
Hide warning "No python interpreters" in auto_silent mode.

Fixes: #74274

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Rick Elrod b0389c7f11
[cli] remove superfluous trailing space from help (#74551)
Change:
- After we output the newline in help text, we also added a space. This
  caused either a space to show up before the shell prompt (in shells
  like bash), or " %" and a newline before the next prompt on shells
  like zsh that automatically force commands to end with a newline.
- This change removes the extra space, so that peace can be restored in
  the minds of many.
- This only showed up when running commands with no arguments or invalid
  arguments.

Test Plan:
- Ran `ansible`, `ansible -h`, `ansible-playbook`, `ansible-galaxy`, and
  `ansible-galaxy -h`.

Tickets:
- Introduced in #69458

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Brian Coca 30912b6a47
dont specify default for port, allow ssh/config (#74526)
* dont specify default for port, allow ssh/config

 also added general note on how defaults work.

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Sam Doran <sdoran@redhat.com>
3 years ago
Ruairidh MacLeod d101009688
facts - set correct OS family for Rocky Linux (#74530) 3 years ago
Louis Abel 2d41e5f99a
hostname - add Rocky Linux support (#74545) 3 years ago
Matt Clay fb0d5609cb
Code cleanup in ansible-test. (#74529)
* Fix get_available_python_versions calls.
* Make run_playbook vars optional.
* Use ansible_pipelining in inventory.
* Fix type hint.
* Fix order of conditional evaluation.
* Remove unused ibmi platform.
* Add changelog fragment.
3 years ago
Maxim Masiutin daecb30ac9
The apt_key module did not properly handle GnuPG errors for certain actions (#74478)
* Not all GnuPG return codes were analyzed (rc != 0) and not all relevant GnuPG error information was returned by the 'ansible.builtin.apt_key' module (https://github.com/ansible/ansible/issues/74477)

* Update changelogs/fragments/74478-apt_key-gpg-error-check.yaml

Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
Co-authored-by: Sam Doran <sdoran@redhat.com>
3 years ago
Harm Geerts 9bd70045c9
Fix BaseFileCacheModule#keys to respect prefix (#72789)
* Fix BaseFileCacheModule#keys to respect prefix

Change:
- Previously BaseFileCacheModule#keys would return keys with the cache
  prefix. These keys are impossible to retrieve from the cache without
  removing the prefix or using the cache without a prefix.
  Now it removes the prefix from the key and only returns keys that
  share the same prefix as the cache.

Test Plan:
- New unit tests

* Add explicit BaseFileCacheModule#keys test

Test that files that do not match the cache prefix are ignored.
Test that the prefix is removed from the cache key.
3 years ago
Rick Elrod d8c20a73a4
[ansible-test] Add Fedora 34, update Fedora 33 (#74506)
Change:
- Added Fedora 34 container image to docker.txt
- Dropped Fedora 32 from CI
- Added Fedora 34 to CI
- Updated Fedora 32 and 33 containers for ssh-related fixes
- Move cron fix from 698eae3f3d into
  cron_setup and make it more generic; it can affect modern distros too.

Test Plan:
- ci_complete

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Maxim Masiutin 6ea81b84ed
apt_key - correct error message about the failure to import a 'gpg' (#74476) 3 years ago
Matt Clay a30c55f68a Remove deprecated `common.removed` module_util.
Tests have been updated to reflect its removal as well.
3 years ago
David Shrewsbury f1a5c411d9
Fix sequence lookup message and add tests (#74472)
* add test for bad kv arg value
* add simple form parsing tests and make error messages the same
* add changelog
3 years ago
Sam Doran 74b2add460
paramiko_ssh - mark connection as connected when successful (#74459)
* Remove unused import from test
3 years ago
Brian Coca 8a2fc854f4
Add plugin config lists (#49627)
* add plugin config lists
* and dump config for plugins
*  also list configs under PLUGINS for 'all' list
3 years ago
Brian Coca 3cff54d69b
Fix missing delegate display (#74370)
* dont rely on vars, task already gives us info
* ensure we always display delegation in host label
* also added parens with ansible_host to show  target host vs resolved host
* delegating to self is not delegating
* delegated vars restoration for backwards compat
* tests need mock task with delegate_to
3 years ago
Martin Krizek 57d661e96f
Templar: remove _fail_on_{lookup,filter}_errors (#73785)
Both were added in 62d79568be and never
used, always being set to True.
3 years ago
Maxim Masiutin 3bc2e7783c
Binary GnuPG keys downloaded via URLs by the 'ansible.builtin.apt_key' module were corrupted so 'gpg' could not import them (https://github.com/ansible/ansible/issues/74424) (#74474) 3 years ago
Abhijeet Kasurde 9e61952cdc
command - add command name to warning (#74475) 3 years ago
Anatoly Pugachev 04e57d28e3
[facts] add hpux fc info, refactor aix and solaris code (#57406)
* correctly parse device from string
* check for command presence before running them
* check for command presence and return code for solaris and aix as well
* add changelog
3 years ago
Logistic Bot 7099657dd7
Basic: don't call lstat when check_mode (#64279)
While mode is specified in check_mode, don't call lstat.
Since file may not present.

Fixes: #61185
3 years ago
Matt Clay 877e5b3dfe Fix ansible-test AZP build lookup. 3 years ago
Matt Clay c4e76a7f80 Add collection config support to ansible-test. 3 years ago
Matt Clay 8223dfccbe ansible-test - Improve __main__ checks. 3 years ago
Rick Elrod fcbf5c3185
[module_utils] make to_bits actually return (#74409)
Change:
- Instead of returning the `str` type, return the value that was
  calculated.

Test Plan:
- New unit tests.

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Matt Clay cb7f4f1971 Fix pypi-test-container port conflict. 3 years ago
Brian Coca c1879a5011
use versioned doclink for url references (#74245)
* use versioned doclink for url references

Co-authored-by: Felix Fontein <felix@fontein.de>
3 years ago
Brian Coca 85e7108d52
force version on deprecation (#74338) 3 years ago
Brian Coca d8fa2b50d5
Fix world readable setting (#74324)
* Fix world readable setting

   now uses shell option in all cases, the old constant still exists
    as 'documentation' but it not settable.
   also fix the docsite link in warnings/errors

* fix typose#

* fix comment#

* added deprecated to config

* missing :

* import cleanup
3 years ago
Alexander Sowitzki 68bdfd0052 Let unarchive handle huge files
Allow extracting archives that contain files which size exceeds free system memory.

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
3 years ago
Matt Clay ecc5a53288
Update default containers to 3.4.0. (#74415)
* Update default containers to 3.4.0.

The 3.4.0 containers use Python 3.6 (the system Python) for `/usr/bin/python3`.

Python 3.9 continues to be the default Python version selected by `ansible-test` for these containers.

* Fix shebang on build-ansible.py.

Using `python` instead of `python3` allows `ansible-test` python interception and requirements install to function.
3 years ago
Alexandre Garnier 8698855ffd
Case-insensitive set theory filters (#74256)
Fixes #74255

* Fix call to 'unique(case_sensitive=False)' triggering error when falling back to Ansible's version which **is** case-sensitive
* Test multiple situations of 'unique' filter errors with fallback not handling specific parameters

Signed-off-by: Rick Elrod <rick@elrod.me>
Co-authored-by: Rick Elrod <rick@elrod.me>
3 years ago
Fernando Correia 7fd989d008
Detect Homebrew on Mac M1 (Apple Silicon) (#74378)
Homebrew's default install location for macOS on ARM is /opt/homebrew.
Source: https://docs.brew.sh/FAQ

On a Mac M1 (Apple Silicon), homebrew will be installed at
/opt/homebrew/bin/brew.
3 years ago
Matt Clay 6cfe36fa1f
Set ansible-test min controller Python to 3.8. (#74395)
- Version neutral sanity tests now require Python 3.8 or later.
- Unit tests for controller-only code now require Python 3.8 or later.
3 years ago
Matt Clay f541c0af23
Update ansible-test default test container. (#74393)
* Update ansible-test default test container.
* Switch generic Python tests from 3.6 to 3.9.
3 years ago
Paul Arthur 7b5dad2321 validate-modules: don't error on valid Ansible YAML in EXAMPLES 3 years ago
Matt Clay 14ff5e213c Fix ansible-test docker container IP detection. 3 years ago
Matt Martz bf7d4ce260
Abstract away libyaml details into yaml utils (#72607)
* Add yaml utils file and use it

* Linting fix and missing import

* Abstract a few more details

* Parser imports

* Don't use CSafeDumper in AnsibleDumper

* Move and use convert_yaml_objects_to_native when libyaml is present

* yaml_load and yaml_dump, instead of safe_*

* re-use HAS_LIBYAML from utils.yaml

* add changelog fragment

* Address recent changes

* Use representer instead of recursive type converter

* Restore needed import

* move yaml utils to module_utils

* Properly guard imports

* Update from_yaml(_all)? to handle text wrappers with CSafeLoader

* Use yaml utils for legacy_collection_loader

* Add HAS_YAML, and ignore pylint issue

* oops

* GPL->BSD
3 years ago
Brian Coca 6418f368e3
Fix pb subs collapse (#74301)
* fix subdir parsing for plays

  fixes #74283

  Co-authored-by: Nikolaos Kakouros <nkak@kth.se>
3 years ago
Rick Elrod 738132da95
[ansible-test] add freebsd/13.0 remote (#74328)
Change:
- FreeBSD 13.0 was released on the 13th, add it to ansible-test.

Test Plan:
- ci_complete

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Sam Doran 7625c8f3d3
arg_spec - remove unused imports (#74354) 3 years ago
elara-leitstellentechnik 437a08eb6d
Map Debian 8 to Python 2 (#74152)
* Map Debian 8 to Python 2

If Python 3 is installed on Debian 8 Ansible cannot run, as the version
is too old (3.4)

* Add integration test for python interpreter discovery on Debian 8

* fix test issue on Debian 9, add changelog

* un"fix" not broken test :D

Co-authored-by: Fabian Klemp <fabian.klemp@elara-gmbh.de>
Co-authored-by: Matt Davis <mrd@redhat.com>
3 years ago
Matt Clay e6af2d6827 Fix ansible-test coverage traceback when no data.
If no coverage directory exists, ansible-test coverage would traceback.

Now it silently continues just as if the directory was present but empty.
3 years ago
Amin Vakil 49d4442378
Add umask option to user module (#73821)
* Add umask option to user module

* Fail on setting both umask and local: True

* Add integration test

* Add changelog

* Run integration tests only if HOME_MODE is not set

* Run integration tests only on Linux

Co-authored-by: Matt Clay <matt@mystile.com>
3 years ago
Brian Coca 4494ef3a9d
defend against bad or missing crypt (#74304)
* defend against bad or missing crypt

  fixes #74279
3 years ago
Brian Coca 2296da95a2
fix module schema (#74295)
* fix module schema

  not out of date hardcoded list anymore, uses 'current + 4' to
  set valid deprecation targets

Co-authored-by: Matt Clay <matt@mystile.com>
3 years ago
Rick Elrod 9f1513d4c0 [become] Add Solaris chmod ACL fallback
Change:
- Newer Solaris drops setfacl. Add a fallback for its chmod ACL syntax.

Test Plan:
- New units

Tickets:
- Fixes #74282

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Rick Elrod 7d64aebdd3 [become] Fix solaris permissions regression
Change:
- Regression introduced in #70785
- When macOS chmod ACL syntax is used, Solaris-derived chmods return
  with a status of 5. This is also used for our sshpass handling,
  because sshpass will return 5 on auth failure. This means on Solaris,
  we incorrectly assume auth failure when we reach this branch of logic
  and try to run chmod with macOS syntax.
- We now wrap this specific use of chmod in an exception handler that
  looks for AnsibleAuthenticationFailure and skips over it. This adds
  another authentication attempt (something we normally avoid to prevent
  account lockout), but seems better than the regression of not allowing
  other fallbacks to be used.
- Without this patch, if setfacl fails on Solaris (and sshpass is used),
  we do not try common_remote_group or world-readable tmpdir fallbacks.

Test Plan:
- New unit

Signed-off-by: Rick Elrod <rick@elrod.me>
3 years ago
Matt Clay 7786dbbdc1 Split out module/module_utils unit test execution.
- Unit tests for `modules` and `module_utils` are now limited to importing only `ansible.module_utils` from the `ansible` module.
- Unit tests other than `modules` and `module_utils` are now run only on Python versions supported by the controller (Python 3.8+).
- Unit tests are now run in separate contexts (`controller`, `modules`, `module_utils`), each using separate invocations of `pytest`.
3 years ago
Matt Martz 3740d7b028
Only check if play.hosts is a template when the play hasn't been finalized (#73941)
* Extend finalized logic to strategy
* Add changelog fragment
3 years ago
Ganesh Nalawade d8bf4206e4
netconf - handle import error when running in FIPS mode (#73992)
* Handle netconf plugin ncclient import error when running in FIPS mode

*  While running in FIPS mode importing ncclient result in
   InternalError raised by cryptography
*  Refer https://github.com/ansible/ansible/pull/65477
3 years ago
Matt Clay 277a06f641
Clean up ansible-test cloud plugins. (#74322)
- Improve code reuse.
- Add missing type hints, fix existing ones and convert them to PEP 484 style.
- Add missing imports and clean up existing ones.
- Add missing docstrings and clean up existing ones.
3 years ago
Matt Martz 17237c1d88
Deprecate Py2.6 support for target nodes (#74165) 3 years ago
Brian Coca 07939b04f3
[2.12] 'attributes' (#73707)
* wip 'attributes'

* added version added tests

* syntzx

* not bile

* correztlys merges

* moved desc to frag

* simpler as dict

* unused

* clog

* Update lib/ansible/utils/plugin_docs.py

Co-authored-by: Jacob Floyd <cognifloyd@gmail.com>

* unnoted

* added action plugins

* longer list

* add sttri schema

* huh?

* itsdict

* dictit

* yolo

* gnore for now

* moar attribs

* allow extras

* positive

* added loop, documented 'imports'

* support is now none/partial/full

* import_playbook is outside host loop

Co-authored-by: Jacob Floyd <cognifloyd@gmail.com>
3 years ago
Alex Willmer 185d410316
Factor out host_label() in default stdout callback plugin (#73814)
This simplifies rendering the hostname (or hostname+delegated host) in
the default callback module, and reduces code duplication

I've chosen not move where in each handler the host label is rendered,
in case subsequent operations has side effects. However I'm happy to
change that if considered safe.

I've chosen not to change the formatting operator used (%), to avoid
changes in rendering that might result.

Signed-off-by: Alex Willmer <alex@moreati.org.uk>
3 years ago
Amin Vakil a7c8093ce4
[2.12] Add accept_newhostkey option to git module (#73819)
* Add integration test for accept_newhostkey option

* Add changelog
3 years ago
Jordan Borean 019452dda7
uri - fix traceback on multipart-form int value (#74302) 3 years ago