Commit graph

2446 commits

Author SHA1 Message Date
Sam Doran ebe0ed9331
[stable-2.10] hostname - add Almalinux support (#73619) (#73648)
(cherry picked from commit ac0dedda72)

Co-authored-by: Aaron Guise <guisea@users.noreply.github.com>
2021-03-08 04:28:07 -06:00
Sloane Hertel 3e95e3c0a0
galaxy: Handle ignored directory names in role skeleton (#72035) (#73806)
* galaxy: restore left hand slicing in assignment

Fix 'ansible-galaxy role init --role-skeleton=role-skeleton' when the role skeleton
contains an ignored directory.

The issue was because the 'dirs' variable was changed to reference a different list,
but needs to be mutated instead to stop os.walk from traversing ignored directories.

Fixes: #71977

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit eb72c36a71)

Co-authored-by: manas-init <70483021+manas-init@users.noreply.github.com>
2021-03-08 04:26:47 -06:00
Sloane Hertel ece31e1b51
[2.10] find module - stop dir traversal when depth is exceeded (#73808)
* find module - stop traversing directories with os.walk when depth is already exceeded (#73718)

(cherry picked from commit 8628c12f30)

* Update tests since there are fewer prior tasks creating files/directories
2021-03-08 04:18:02 -06:00
Gonéri Le Bouder b1d278a595
ansible-test: yamllint, check the assigment (#73583)
Ensure `yamllint`'s `check_assignment()` correctly ignore the
attribute assignment. Those don't have any `.id` attribute and will
trigger an `AttributeError` exception.

See: https://github.com/ansible/ansible/pull/73322
(cherry picked from commit 0a8d5c0983)
2021-03-08 04:16:09 -06:00
Alexander Sowitzki ab8bbe269d
[stable-2.10] Let vault lookup output unicode string. (#73571) (#73573)
Until now, the lookup plugin returned a byte string.
Changed this to output a unicode string instead.
(cherry picked from commit d0fda3e901)

Co-authored-by: Alexander Sowitzki <asowitzk@redhat.com>
2021-03-08 04:15:28 -06:00
Gonéri Le Bouder e85732f7e6
[ansible-test] attempt to work around podman (#72096) (#73569)
Change:
- podman > 2 && < 2.2 does not support "images --format {{json .}}"
- podman also now outputs images JSON differently than docker
- Work around both of the above.

Test Plan:
- Tested with podman 2.0.6 in Fedora 31.

Signed-off-by: Rick Elrod <rick@elrod.me>
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
(cherry picked from commit 0332046699)

Co-authored-by: Rick Elrod <rick@elrod.me>
2021-03-08 04:12:38 -06:00
Brian Coca 2f51105936
only add data when there is data to add (#54559) (#73566)
Only add data when there is data to add

  also avoid clobbering existing data with empty file
  fixes #45843

* remove redundant code, update comments
* fix mock dataloader, original does not return None
* added test

(cherry picked from commit ec8a556538)
2021-03-08 04:07:44 -06:00
Sam Doran 77b76a3270
[stable-2.10] Add AlmaLinux to the family of Red Hat-like operating systems (#73541) (#73543)
* Add changelog and fixtures for AlmaLinux support

Co-authored-by: Christoph Schug <com+github@schug.net>
(cherry picked from commit 2f5c83dfb1)

Co-authored-by: Sam Doran <sdoran@redhat.com>
2021-03-08 03:14:54 -06:00
Matt Martz d720a5e42c
[stable-2.10] Don't treat host_pinned as lockstep (#73484) (#73504)
* [stable-2.10] Don't treat host_pinned as lockstep (#73484)

* Don't treat host_pinned as lockstep. Fixes #73364

* Add intg tests.
(cherry picked from commit d3f3784b86)

Co-authored-by: Matt Martz <matt@sivel.net>

* Make non-lockstep callback tests more deterministic (#73511)

(cherry picked from commit 125c220343)
2021-03-08 03:14:02 -06:00
Matt Clay b998f7050b
[stable-2.10] Fix ansible-test handling of egg-info. (#73595)
* Add test to verify pkg_resources imports work.

(cherry picked from commit 133a29acb4)

* [stable-2.10] Fix ansible-test handling of egg-info.

Resolves https://github.com/ansible/ansible/issues/67990.
(cherry picked from commit d092356fc5)

Co-authored-by: Matt Clay <matt@mystile.com>
2021-03-02 11:12:44 -08:00
Rick Elrod 9ea56ff292 New release v2.10.6 2021-02-17 16:10:38 -06:00
Rick Elrod 244fdf324c New release v2.10.6rc1 2021-02-08 19:01:35 -06:00
Matt Clay aedc7301f6
[stable-2.10] Temporary fix for cryptography issues. (#73530). (#73533)
(cherry picked from commit 1a2da990a4)

Co-authored-by: Matt Clay <mclay@redhat.com>
2021-02-08 17:21:15 -06:00
Felix Fontein 5411090f51 Bump antsibull-changelog version for changelog sanity test.
(cherry picked from commit 82cdd7e735)
2021-02-08 09:04:07 -08:00
Sam Doran f9572a377d
[stable-2.10] pause - adjust warning when run in background (#73182) (#73231)
When the pause module is run in the background and seconds parameter is provided,
do not warn.

* Add tests
* Fix existing tests
  The test wasn't failing when it should have.
(cherry picked from commit 0e6c334115)

Co-authored-by: Sam Doran <sdoran@redhat.com>
2021-02-07 17:57:31 -06:00
Jordan Borean bca57ec65a
bugfix: use to_text(stdout) in psrp.Connection.put_file method (#73491) - 2.10 (#73496)
(cherry picked from commit f271d02a9f)

Co-authored-by: jakegatsby <39974194+jakegatsby@users.noreply.github.com>
2021-02-07 17:56:59 -06:00
Sam Doran e75570ba83
[stable-2.10] Fix YAML error message when error is at the end of the file (#73241) (#73296)
If a YAML file fails to load due to a syntax error in a file, or there is an error in the last line of a
file, PyYAML reports the last line number of the file as the index where the error occurred.

When reading the file lines, we use that index to the get the relevant line.  If the index value is out
of range, the relevant line is lost for error reporting.

Subtract one from the index value to avoid the IndexError in this specific scenario. It is possible
to still get an IndexError, which will be handled as it is currently.

* Update existing tests and add new tests
(cherry picked from commit e8d4b62b41)

Co-authored-by: Sam Doran <sdoran@redhat.com>
2021-02-07 17:56:17 -06:00
Brian Coca 3ef061bdc4
Use a pty for local connections (#73023) (#73281)
Fixes #38696

Co-authored-by: James Cammarata <jimi@sngx.net>
(cherry picked from commit 30d93995dd)
2021-02-07 17:53:10 -06:00
Felix Fontein 63ead90ab9
Always mention the name of the deprecated plugin in routing deprecation messages (#73059) (#73237)
(cherry picked from commit df9cf368c0)
2021-02-07 17:52:29 -06:00
Sam Doran 70fb5ae36a
[stable-2.10] facts - properly report virtualization facts for Linux guests on bhyve (#73204). (#73233)
(cherry picked from commit df451636e7)

Co-authored-by: Sam Doran <sdoran@redhat.com>
2021-02-07 17:50:49 -06:00
Brian Coca 9478b59da5
fix inventory source parse error handling (#73160) (#73276)
fixes #51025

added test cases

(cherry picked from commit 1e27d4052a)
2021-02-07 17:29:07 -06:00
Martin Krizek 2c8c02c816
Local vars should have highest precedence in AnsibleJ2Vars (#72830) (#73370)
Ability to add local variables into AnsibleJ2Vars was added in
18a9eff11f to fix #6653. Local variables
are added using ``AnsibleJ2Vars.add_locals()`` method when creating a
new context - typically when including/importing a template with
context. For that use case local template variables created using
``set`` should override variables from higher contexts - either from the
play or any parent template, or both; Jinja behaves the same way.

Also removes AnsibleJ2Vars.extras instance variable which is not used.

Also adds missing test for #6653.

Fixes #72262
Fixes #72615

ci_complete

(cherry picked from commit a2af8432f3)
2021-02-07 01:30:47 -06:00
Jordan Borean e41d1f0a3f
no_log mask suboption fallback values and defaults CVE-2021-20228 (#73487) (#73494)
(cherry picked from commit 0cdc410dce)
2021-02-07 01:11:27 -06:00
Rick Elrod 015ec3eda8
git: verify, only use --raw when we need it (#70900) (#73473)
Change:
- Allow older git to verify tags again
- Enable verification tests everywhere, even if most of them only work
  on newer git. Some of them work on older git and they test the --raw
  parameter.

Test Plan:
- Re-enabled subset of git tests

Tickets:
- Fixes #64469

Signed-off-by: Rick Elrod <rick@elrod.me>
2021-02-07 01:08:04 -06:00
Sloane Hertel 6df8a9ec53
Fix warning for nonexistent inventory cache (#72840) (#73443)
* Fix inventory cache warning by checking if the key exists before loading it

(cherry picked from commit 840bdc1e10)
2021-02-07 01:05:20 -06:00
Brian Coca 148240099a
ensure unsafe writes fallback (#70722) (#73144)
* Ensure we actually fallback to unsafe_writes when set to true

 add integration test
 add fix for get_url not passing the parameter from args

(cherry picked from commit 932ba36160)

* Added clog missing for issue 70722 (#73175)

(cherry picked from commit d6670da1d7)
2021-02-07 01:03:43 -06:00
Sam Doran e9c6b382ea
[stable-2.10] import_playbook - change additional params to deprecation (#72987) (#73015)
I incorrectly recommended this be set as a warning when it should have been a deprecation.

* Fix deprecation sanity test to not required a collection name when not inside a collection
(cherry picked from commit 8e022ef00a)

Co-authored-by: Sam Doooran <sdoran@redhat.com>
2021-02-07 00:52:15 -06:00
Gonéri Le Bouder 985a395cd9 validate_modules: fails with .id attribute not found (#73322)
* validate_modules: fails with .id attribute not found

This patch addresses a problem in the `found_try_except_import` test.

This module tries to identify lines like:

`HAS_FOO = True`

In this case, the target (`HAS_FOO`) is of type `ast.Name` and has a
`id` attribute which provide the name.

In my case, I've a line that set a module attribute`. In this case, the
target (`module.var`) has the type `ast.Attribute` and no `id`
attribute. The code trigger an `AttributeError` exception.

This patch ensures we compare a `ast.Name`.

* Update test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py

(cherry picked from commit 7cf80f50d1)
2021-02-03 09:07:14 -08:00
Rick Elrod a3175e9979
Revert "[ansible-test] Bump CentOS 6 image (yum repos) (#73446) (#73447)" (#73450)
This reverts commit e4f8d528b9.
2021-02-01 22:02:55 -06:00
Rick Elrod e4f8d528b9
[ansible-test] Bump CentOS 6 image (yum repos) (#73446) (#73447)
Change:
- Bump centos6 image version to one which includes multiple fallbacks
  for vault.centos.org content.

Signed-off-by: Rick Elrod <rick@elrod.me>
2021-02-01 18:37:24 -06:00
Rick Elrod 356aae0e23
[2.10] Add Ubuntu 20.04 to CI and ansible-test (#69161) (#73365)
Change:
- Add Ubuntu 20.04 to CI now that venv is default instead of virtualenv in ansible-test.

Test Plan:
- CI

Tickets:
- Fixes #69203

Signed-off-by: Rick Elrod <rick@elrod.me>
2021-01-26 13:01:31 -06:00
Matt Clay c47ec375fa
[stable-2.10] Use a versioned pip bootstrapper in ansible-test. (#73359)
(cherry picked from commit fc590aeb21)

Co-authored-by: Matt Clay <matt@mystile.com>
2021-01-25 15:37:30 -06:00
Matt Clay 1f90c11782 [stable-2.10] Handle get-pip.py breaking change on Python 2.7.
(cherry picked from commit 484e4af4d0)

Co-authored-by: Matt Clay <matt@mystile.com>
2021-01-23 12:36:28 -08:00
Rick Elrod 890601dcef New release v2.10.5 2021-01-18 14:34:40 -06:00
Rick Elrod 422b9c09ee New release v2.10.5rc1 2021-01-11 17:33:09 -06:00
Sloane Hertel 08ba838a8e
[2.10] Pass the top level dictionaries to combine_vars (#72979) (#73146)
combine_vars uses dict.update() to replace keys

(cherry picked from commit 5e03e322de)

* Add tests for merging and replacing vars from inventory sources (#73181)

(cherry picked from commit 9de2da8a7e)
2021-01-11 17:20:48 -06:00
Sam Doran abc6658ac2
[stable-2.10] Add macOS 11 to CI (#72622) (#73180)
* [stable-2.10] Add macOS 11 to CI (#72622)

* Fix connection_paramiko_ssh test for macOS 11
* Update Azure Pipelines config
* Add changelog
(cherry picked from commit a7e834071c)

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

* Prefer venv for tests

* Update pip integration test to use venv on py3.

(cherry picked from commit 456e9b7a33)

Co-authored-by: Matt Clay <matt@mystile.com>
2021-01-11 16:45:58 -06:00
Sam Doran b4b1bf9932
[stable-2.10] user - properly handle password and password lock when used together (#73016) (#73177)
Do the right thing on Linux when password lock and a password hash are provided by writing
out the password hash prepended by the appropriate lock string rather than using -U and -L.
This is the correct way to set and lock the account in one command.

On BSD, run separate commands as appropriate since locking and setting the password cannot
be done in a single action.

FreeBSD requires running several commands to get the account in the desired state. As a result,
the rc, output, and error from all commands need to be combined and evaluated so an accurate
and complete summary can be given at the end of module execution.

* Improve integration tests to cover this scenario.
* Break up user integration tests into smaller files
* Properly lock account when creating a new account and password is supplied

* Simplify rc collection in FreeBSD class
  Since the _handle_lock() method was added, the rc would be set to None, which could make
  task change reporting incorrect. My first attempt to solve this used a set and was a bit too
  complicated. Simplify it my comparing the rc from _handle_lock() and the current value of rc.

* Improve the Linux password hash and locking behavior
  If password lock and hash are provided, set the hash and lock the account by using a password
  hash since -L cannot be used with -p.

* Ensure -U and -L are not combined with -p since they are mutually exclusive to usermod.

* Clarify password_lock behavior..
(cherry picked from commit 264e08f21a)

Co-authored-by: Sam Doran <sdoran@redhat.com>
2021-01-11 13:11:26 -06:00
Matt Martz 6ba066fc9e
[stable-2.10] Fix async interpreter parsing (#72636) (#72923)
Fixes #70690
(cherry picked from commit 83764ad)
2021-01-11 01:02:33 -06:00
Sam Doran b22d97b2c1
[stable-2.10] Fix string/bytestring comparsion in m_u.basic (#70439) (#73129)
Change:
- module_utils.basic.is_special_selinux_path() used a string ==
  bytestring comparison which returned False and made Ansible think that
  certain filesystems aren't, in fact, special-cased, when they should
  be. Ensure both sides of the == are bytestrings.

Test Plan:
- Added `copy` integration tests for this case.

Tickets:
- Fixes #70244

Signed-off-by: Rick Elrod <rick@elrod.me>.
(cherry picked from commit 688cd8657b)
2021-01-11 00:55:15 -06:00
Sam Doran 1cd09b1ebc
[stable-2.10] systemd - do not overwrite unit name when searching (#72985) (#73013)
PR #72702 introduced a bug that changed the unit name when splitting it up for the purpose
of searching for the unit. This only happens on unit file templates on systems that have a 5.8
or newer kernel and a version of systemd that does not contain a bugfix that causes systmed
to fail to parse dbus.

* Use facts rather than a manual probe to determine if systmed is present
* Remove unnecessary block
* Use vars files instead of set_fact
* Add tests for using a templated unit file
* Update changelog fragment
* Use template to get correct path to sleep binary
(cherry picked from commit 48803604cd)

Co-authored-by: Sam Doooran <sdoran@redhat.com>
2021-01-11 00:47:00 -06:00
Matt Clay cf21e699d4
Update ansible-test pylint Python support. (#72997)
* Rename pylint plugin and add tests. (#70225)
* Update ansible-test pylint Python support. (#72972)
* Add integration tests for sanity test failures.
(cherry picked from commit fa48678a08)

* Python 3.8 is now officially supported.
* Python 3.9 is now skipped with a warning.
(cherry picked from commit 37d09f2488)

* Allow key None to prevent errors with import test.
(cherry picked from commit dbc2c996ab)

Backport of https://github.com/ansible/ansible/pull/73003

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-01-11 00:46:21 -06:00
Jordan Borean c5248f756c
Collection list site packages (#70173) (#72940)
* ansible-galaxy collection list and verify now utilize collections in site-packages.

This is a short term fix for #70147.  The long term fix needs to handle
install (but that discussion is also bound up in how upgrade is going to
work and where things can get installed so it's deferred for 2.11.)

* Add test for ansible-galaxy collection list with site-packages

Co-authored-by: David Moreau Simard <moi@dmsimard.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
(cherry picked from commit e7dee73774)

Co-authored-by: Toshio Kuratomi <a.badger@gmail.com>
2021-01-11 00:41:56 -06:00
Matt Martz 511ffdeff7
[stable-2.10] Fix reset_connection paramiko, winrm, psrp (#72688) (#72925)
* Ensure we only reset the connection when one has been previously established. Fixes #65812

* Ensure psrp doesn't trace

* winrm too

* Indentation fix
(cherry picked from commit a3b6485)

Co-authored-by: Matt Martz <matt@sivel.net>
2021-01-11 00:36:05 -06:00
Sloane Hertel 82b75282fc
Fix task get_name to always prepend the role name (#72511) (#72919)
* Fix 'role_name : tast_name' notation if task contains role name

* Add tests for notifying handler names which contain the role name

Co-authored-by: Thomas Wouters <thomaswouters@gmail.com>
(cherry picked from commit 0ed7bfc694)
2021-01-11 00:28:57 -06:00
Martin Krizek a5df30e2bf
Use _wrap_native_text only for builtin STRING_TYPE_FILTERS (#71801) (#72915)
(cherry picked from commit 252685092c)
2021-01-11 00:22:01 -06:00
Jon "The Nice Guy" Spriggs 2f3e9a38b6
Backport/2.10/73079 (#73165)
* Update apt.py, add an example that references the suggested workaround in #25414
(cherry picked from commit 1e1b8e7aca)
(cherry picked from commit 180bbfed6a)

* Added changelog fragment
2021-01-08 16:38:44 -06:00
Matt Clay 4452d98662
Support venv in ansible-test virtualenv scripts (#73163)
* ansible-test - prefer venv over virtualenv on Python 3 (#73000)

Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed
anway with the previous constraint (<20).

On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since
some systems have a non-functional venv installation (such as Debian).

(cherry picked from commit 850a77f639)

* Make the new ansible-test venv behavior opt-in

Co-authored-by: Sam Doooran <sdoran@redhat.com>
2021-01-08 16:31:17 -06:00
Rick Elrod 436d8a13b4 New release v2.10.4 2020-12-14 14:44:44 -06:00
Matt Clay 12b33c79ee
[stable-2.10] Fix cryptography constraints in ansible-test. (#72914) (#72922)
(cherry picked from commit 36ab3d1189)

Co-authored-by: Matt Clay <mclay@redhat.com>
2020-12-09 14:41:15 -06:00