ansible-core 2.19.2__py3-none-any.whl → 2.20.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansible-core might be problematic. Click here for more details.
- ansible/_internal/__init__.py +1 -4
- ansible/_internal/_ansiballz/_builder.py +1 -3
- ansible/_internal/_collection_proxy.py +7 -9
- ansible/_internal/_display_utils.py +145 -0
- ansible/_internal/_json/__init__.py +3 -4
- ansible/_internal/_templating/_engine.py +1 -1
- ansible/_internal/_templating/_jinja_plugins.py +1 -2
- ansible/_internal/_wrapt.py +105 -301
- ansible/cli/__init__.py +11 -10
- ansible/cli/adhoc.py +1 -2
- ansible/cli/arguments/option_helpers.py +1 -1
- ansible/cli/config.py +5 -6
- ansible/cli/doc.py +67 -67
- ansible/cli/galaxy.py +15 -24
- ansible/cli/inventory.py +0 -1
- ansible/cli/playbook.py +0 -1
- ansible/cli/pull.py +0 -1
- ansible/cli/scripts/ansible_connection_cli_stub.py +1 -1
- ansible/config/base.yml +1 -25
- ansible/config/manager.py +0 -2
- ansible/executor/play_iterator.py +42 -20
- ansible/executor/playbook_executor.py +0 -9
- ansible/executor/powershell/async_watchdog.ps1 +24 -4
- ansible/executor/task_executor.py +32 -22
- ansible/executor/task_queue_manager.py +1 -3
- ansible/galaxy/api.py +33 -80
- ansible/galaxy/collection/__init__.py +4 -17
- ansible/galaxy/dependency_resolution/dataclasses.py +0 -10
- ansible/galaxy/dependency_resolution/providers.py +1 -2
- ansible/galaxy/role.py +1 -33
- ansible/inventory/manager.py +2 -3
- ansible/keyword_desc.yml +0 -3
- ansible/module_utils/_internal/_datatag/__init__.py +2 -10
- ansible/module_utils/_internal/_no_six.py +86 -0
- ansible/module_utils/_text.py +28 -8
- ansible/module_utils/ansible_release.py +2 -2
- ansible/module_utils/basic.py +27 -24
- ansible/module_utils/common/_collections_compat.py +11 -2
- ansible/module_utils/common/collections.py +8 -3
- ansible/module_utils/common/dict_transformations.py +1 -2
- ansible/module_utils/common/network.py +4 -2
- ansible/module_utils/common/parameters.py +32 -41
- ansible/module_utils/common/text/converters.py +109 -23
- ansible/module_utils/common/text/formatters.py +6 -2
- ansible/module_utils/common/validation.py +11 -9
- ansible/module_utils/connection.py +8 -3
- ansible/module_utils/facts/hardware/linux.py +23 -7
- ansible/module_utils/facts/hardware/netbsd.py +1 -1
- ansible/module_utils/facts/hardware/sunos.py +2 -1
- ansible/module_utils/facts/packages.py +6 -2
- ansible/module_utils/facts/system/distribution.py +2 -1
- ansible/module_utils/facts/system/env.py +6 -3
- ansible/module_utils/facts/system/local.py +3 -1
- ansible/module_utils/parsing/convert_bool.py +6 -2
- ansible/module_utils/service.py +2 -3
- ansible/module_utils/six/__init__.py +11 -6
- ansible/module_utils/urls.py +6 -2
- ansible/module_utils/yumdnf.py +0 -5
- ansible/modules/apt.py +18 -13
- ansible/modules/apt_repository.py +1 -1
- ansible/modules/assemble.py +5 -9
- ansible/modules/blockinfile.py +39 -23
- ansible/modules/cron.py +26 -35
- ansible/modules/deb822_repository.py +83 -12
- ansible/modules/dnf.py +3 -7
- ansible/modules/dnf5.py +4 -6
- ansible/modules/expect.py +0 -3
- ansible/modules/find.py +1 -2
- ansible/modules/get_url.py +1 -1
- ansible/modules/git.py +4 -5
- ansible/modules/include_vars.py +1 -1
- ansible/modules/lineinfile.py +71 -63
- ansible/modules/package_facts.py +1 -1
- ansible/modules/pip.py +8 -2
- ansible/modules/replace.py +6 -6
- ansible/modules/service.py +3 -4
- ansible/modules/stat.py +20 -0
- ansible/modules/uri.py +9 -10
- ansible/modules/user.py +1 -2
- ansible/modules/wait_for.py +2 -2
- ansible/modules/wait_for_connection.py +2 -1
- ansible/modules/yum_repository.py +1 -16
- ansible/parsing/dataloader.py +24 -31
- ansible/parsing/mod_args.py +3 -0
- ansible/parsing/vault/__init__.py +1 -2
- ansible/playbook/base.py +8 -56
- ansible/playbook/block.py +0 -60
- ansible/playbook/collectionsearch.py +1 -2
- ansible/playbook/handler.py +1 -7
- ansible/playbook/helpers.py +0 -7
- ansible/playbook/included_file.py +1 -1
- ansible/playbook/play.py +103 -37
- ansible/playbook/play_context.py +4 -0
- ansible/playbook/role/__init__.py +10 -65
- ansible/playbook/role/definition.py +3 -4
- ansible/playbook/role/include.py +2 -3
- ansible/playbook/role/metadata.py +1 -12
- ansible/playbook/role/requirement.py +1 -2
- ansible/playbook/role_include.py +1 -2
- ansible/playbook/taggable.py +16 -5
- ansible/playbook/task.py +51 -55
- ansible/plugins/action/__init__.py +20 -19
- ansible/plugins/action/add_host.py +1 -2
- ansible/plugins/action/fetch.py +2 -4
- ansible/plugins/action/group_by.py +1 -2
- ansible/plugins/action/include_vars.py +20 -22
- ansible/plugins/action/script.py +1 -3
- ansible/plugins/action/template.py +1 -2
- ansible/plugins/action/uri.py +4 -2
- ansible/plugins/cache/__init__.py +1 -0
- ansible/plugins/callback/__init__.py +13 -6
- ansible/plugins/connection/__init__.py +3 -7
- ansible/plugins/connection/local.py +2 -3
- ansible/plugins/connection/psrp.py +0 -2
- ansible/plugins/connection/ssh.py +2 -7
- ansible/plugins/connection/winrm.py +0 -2
- ansible/plugins/doc_fragments/result_format_callback.py +15 -0
- ansible/plugins/filter/core.py +4 -5
- ansible/plugins/filter/encryption.py +3 -27
- ansible/plugins/filter/mathstuff.py +1 -2
- ansible/plugins/filter/to_nice_yaml.yml +31 -3
- ansible/plugins/filter/to_yaml.yml +29 -12
- ansible/plugins/inventory/__init__.py +1 -2
- ansible/plugins/inventory/script.py +2 -1
- ansible/plugins/inventory/toml.py +3 -6
- ansible/plugins/inventory/yaml.py +1 -2
- ansible/plugins/list.py +10 -3
- ansible/plugins/loader.py +6 -6
- ansible/plugins/lookup/password.py +1 -2
- ansible/plugins/lookup/subelements.py +2 -3
- ansible/plugins/lookup/url.py +1 -1
- ansible/plugins/lookup/varnames.py +1 -2
- ansible/plugins/shell/__init__.py +9 -4
- ansible/plugins/shell/powershell.py +8 -24
- ansible/plugins/strategy/__init__.py +6 -3
- ansible/plugins/test/core.py +4 -1
- ansible/plugins/test/regex.yml +18 -6
- ansible/release.py +2 -2
- ansible/template/__init__.py +3 -7
- ansible/utils/collection_loader/_collection_config.py +5 -0
- ansible/utils/collection_loader/_collection_finder.py +11 -14
- ansible/utils/context_objects.py +7 -4
- ansible/utils/display.py +28 -167
- ansible/utils/encrypt.py +0 -5
- ansible/utils/helpers.py +6 -2
- ansible/utils/jsonrpc.py +7 -3
- ansible/utils/plugin_docs.py +49 -38
- ansible/utils/ssh_functions.py +0 -19
- ansible/utils/unsafe_proxy.py +7 -7
- ansible/vars/clean.py +2 -3
- ansible/vars/manager.py +27 -20
- ansible/vars/plugins.py +1 -31
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/METADATA +3 -3
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/RECORD +200 -200
- ansible_test/_data/completion/docker.txt +7 -7
- ansible_test/_data/completion/network.txt +0 -1
- ansible_test/_data/completion/remote.txt +4 -4
- ansible_test/_data/requirements/ansible-test.txt +1 -1
- ansible_test/_data/requirements/sanity.changelog.txt +1 -1
- ansible_test/_data/requirements/sanity.pep8.txt +1 -1
- ansible_test/_data/requirements/sanity.pylint.txt +4 -4
- ansible_test/_internal/cache.py +2 -5
- ansible_test/_internal/cli/compat.py +1 -1
- ansible_test/_internal/commands/coverage/combine.py +1 -3
- ansible_test/_internal/commands/integration/__init__.py +3 -7
- ansible_test/_internal/commands/integration/cloud/httptester.py +1 -1
- ansible_test/_internal/commands/integration/coverage.py +1 -3
- ansible_test/_internal/commands/integration/filters.py +5 -10
- ansible_test/_internal/commands/sanity/validate_modules.py +1 -5
- ansible_test/_internal/commands/units/__init__.py +1 -13
- ansible_test/_internal/completion.py +2 -5
- ansible_test/_internal/config.py +2 -7
- ansible_test/_internal/coverage_util.py +1 -1
- ansible_test/_internal/delegation.py +2 -0
- ansible_test/_internal/docker_util.py +1 -1
- ansible_test/_internal/host_profiles.py +6 -11
- ansible_test/_internal/provider/__init__.py +2 -5
- ansible_test/_internal/provisioning.py +2 -5
- ansible_test/_internal/pypi_proxy.py +1 -1
- ansible_test/_internal/target.py +2 -6
- ansible_test/_internal/thread.py +1 -4
- ansible_test/_internal/util.py +9 -14
- ansible_test/_util/controller/sanity/code-smell/runtime-metadata.py +14 -19
- ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py +30 -27
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +31 -18
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py +1 -2
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py +59 -71
- ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py +1 -2
- ansible_test/_util/target/cli/ansible_test_cli_stub.py +4 -2
- ansible_test/_util/target/common/constants.py +2 -2
- ansible_test/_util/target/setup/bootstrap.sh +0 -6
- ansible/utils/py3compat.py +0 -27
- ansible_test/_data/pytest/config/legacy.ini +0 -4
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/WHEEL +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/entry_points.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/COPYING +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/Apache-License.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/BSD-3-Clause.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/MIT-license.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/PSF-license.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/simplified_bsd.txt +0 -0
- {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import types
|
|
5
|
+
|
|
6
|
+
from ansible.module_utils.common import warnings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# INLINED FROM THE SIX LIBRARY, see lib/ansible/module_utils/six/__init__.py
|
|
10
|
+
# Copyright (c) 2010-2024 Benjamin Peterson
|
|
11
|
+
def with_metaclass(meta, *bases):
|
|
12
|
+
"""Create a base class with a metaclass."""
|
|
13
|
+
|
|
14
|
+
# This requires a bit of explanation: the basic idea is to make a dummy
|
|
15
|
+
# metaclass for one level of class instantiation that replaces itself with
|
|
16
|
+
# the actual metaclass.
|
|
17
|
+
class metaclass(type):
|
|
18
|
+
|
|
19
|
+
def __new__(cls, name, this_bases, d):
|
|
20
|
+
if sys.version_info[:2] >= (3, 7):
|
|
21
|
+
# This version introduced PEP 560 that requires a bit
|
|
22
|
+
# of extra care (we mimic what is done by __build_class__).
|
|
23
|
+
resolved_bases = types.resolve_bases(bases)
|
|
24
|
+
if resolved_bases is not bases:
|
|
25
|
+
d['__orig_bases__'] = bases
|
|
26
|
+
else:
|
|
27
|
+
resolved_bases = bases
|
|
28
|
+
return meta(name, resolved_bases, d)
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def __prepare__(cls, name, this_bases):
|
|
32
|
+
return meta.__prepare__(name, bases)
|
|
33
|
+
|
|
34
|
+
return type.__new__(metaclass, 'temporary_class', (), {})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def add_metaclass(metaclass):
|
|
38
|
+
"""Class decorator for creating a class with a metaclass."""
|
|
39
|
+
|
|
40
|
+
def wrapper(cls):
|
|
41
|
+
orig_vars = cls.__dict__.copy()
|
|
42
|
+
slots = orig_vars.get('__slots__')
|
|
43
|
+
if slots is not None:
|
|
44
|
+
if isinstance(slots, str):
|
|
45
|
+
slots = [slots]
|
|
46
|
+
for slots_var in slots:
|
|
47
|
+
orig_vars.pop(slots_var)
|
|
48
|
+
orig_vars.pop('__dict__', None)
|
|
49
|
+
orig_vars.pop('__weakref__', None)
|
|
50
|
+
if hasattr(cls, '__qualname__'):
|
|
51
|
+
orig_vars['__qualname__'] = cls.__qualname__
|
|
52
|
+
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
|
53
|
+
|
|
54
|
+
return wrapper
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def iteritems(d, **kw):
|
|
58
|
+
return iter(d.items(**kw))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
_mini_six = {
|
|
62
|
+
"PY2": False,
|
|
63
|
+
"PY3": True,
|
|
64
|
+
"text_type": str,
|
|
65
|
+
"binary_type": bytes,
|
|
66
|
+
"string_types": (str,),
|
|
67
|
+
"integer_types": (int,),
|
|
68
|
+
"iteritems": iteritems,
|
|
69
|
+
"add_metaclass": add_metaclass,
|
|
70
|
+
"with_metaclass": with_metaclass,
|
|
71
|
+
}
|
|
72
|
+
# INLINED SIX END
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def deprecate(importable_name: str, module_name: str, *deprecated_args) -> object:
|
|
76
|
+
"""Inject import-time deprecation warnings."""
|
|
77
|
+
if not (importable_name in deprecated_args and (importable := _mini_six.get(importable_name, ...) is not ...)):
|
|
78
|
+
raise AttributeError(f"module {module_name!r} has no attribute {importable_name!r}")
|
|
79
|
+
|
|
80
|
+
# TODO Inspect and remove all calls to this function in 2.24
|
|
81
|
+
warnings.deprecate(
|
|
82
|
+
msg=f"Importing {importable_name!r} from {module_name!r} is deprecated.",
|
|
83
|
+
version="2.24",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return importable
|
ansible/module_utils/_text.py
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
# Copyright (c), Toshio Kuratomi <tkuratomi@ansible.com> 2016
|
|
2
2
|
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
|
3
3
|
|
|
4
|
-
"""
|
|
5
|
-
.. warn:: Use ansible.module_utils.common.text.converters instead.
|
|
6
|
-
"""
|
|
7
4
|
from __future__ import annotations
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
# pylint: disable=unused-import
|
|
11
|
-
import codecs
|
|
6
|
+
from ansible.module_utils.common import warnings as _warnings
|
|
12
7
|
|
|
13
|
-
from ansible.module_utils.six import PY3, text_type, binary_type
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
_mini_six = {
|
|
10
|
+
"binary_type": bytes,
|
|
11
|
+
"text_type": str,
|
|
12
|
+
"PY3": True,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __getattr__(importable_name: str) -> object:
|
|
17
|
+
"""Inject import-time deprecation warnings."""
|
|
18
|
+
help_text: str | None = None
|
|
19
|
+
importable: object
|
|
20
|
+
if importable_name == "codecs":
|
|
21
|
+
import codecs
|
|
22
|
+
importable = codecs
|
|
23
|
+
elif importable_name in {"to_bytes", "to_native", "to_text"}:
|
|
24
|
+
from ansible.module_utils.common.text import converters
|
|
25
|
+
importable = getattr(converters, importable_name)
|
|
26
|
+
help_text = "Use ansible.module_utils.common.text.converters instead."
|
|
27
|
+
elif (importable := _mini_six.get(importable_name, ...)) is ...:
|
|
28
|
+
raise AttributeError(f"module {__name__!r} has no attribute {importable_name!r}")
|
|
29
|
+
|
|
30
|
+
_warnings.deprecate(
|
|
31
|
+
msg=f"Importing {importable_name!r} from {__name__!r} is deprecated.",
|
|
32
|
+
version="2.24",
|
|
33
|
+
help_text=help_text,
|
|
34
|
+
)
|
|
35
|
+
return importable
|
ansible/module_utils/basic.py
CHANGED
|
@@ -11,12 +11,13 @@ import typing as t
|
|
|
11
11
|
|
|
12
12
|
# Used for determining if the system is running a new enough python version
|
|
13
13
|
# and should only restrict on our documented minimum versions
|
|
14
|
-
_PY_MIN = (3,
|
|
14
|
+
_PY_MIN = (3, 9)
|
|
15
15
|
|
|
16
16
|
if sys.version_info < _PY_MIN:
|
|
17
17
|
print(json.dumps(dict(
|
|
18
18
|
failed=True,
|
|
19
|
-
msg=f"
|
|
19
|
+
msg=f"Ansible requires Python {'.'.join(map(str, _PY_MIN))} or newer on the target. "
|
|
20
|
+
f"Current version: {''.join(sys.version.splitlines())}",
|
|
20
21
|
)))
|
|
21
22
|
sys.exit(1)
|
|
22
23
|
|
|
@@ -45,6 +46,15 @@ import tempfile
|
|
|
45
46
|
import time
|
|
46
47
|
import traceback
|
|
47
48
|
|
|
49
|
+
from collections.abc import (
|
|
50
|
+
KeysView,
|
|
51
|
+
Mapping,
|
|
52
|
+
MutableMapping,
|
|
53
|
+
Sequence,
|
|
54
|
+
MutableSequence,
|
|
55
|
+
Set,
|
|
56
|
+
MutableSet,
|
|
57
|
+
)
|
|
48
58
|
from functools import reduce
|
|
49
59
|
|
|
50
60
|
try:
|
|
@@ -122,13 +132,6 @@ def _get_available_hash_algorithms():
|
|
|
122
132
|
AVAILABLE_HASH_ALGORITHMS = _get_available_hash_algorithms()
|
|
123
133
|
|
|
124
134
|
from ansible.module_utils.common import json as _json
|
|
125
|
-
|
|
126
|
-
from ansible.module_utils.six.moves.collections_abc import (
|
|
127
|
-
KeysView,
|
|
128
|
-
Mapping, MutableMapping,
|
|
129
|
-
Sequence, MutableSequence,
|
|
130
|
-
Set, MutableSet,
|
|
131
|
-
)
|
|
132
135
|
from ansible.module_utils.common.locale import get_best_parsable_locale
|
|
133
136
|
from ansible.module_utils.common.process import get_bin_path
|
|
134
137
|
from ansible.module_utils.common.file import (
|
|
@@ -2090,7 +2093,7 @@ class AnsibleModule(object):
|
|
|
2090
2093
|
stdout_changed = False
|
|
2091
2094
|
for key, event in events:
|
|
2092
2095
|
b_chunk = key.fileobj.read(32768)
|
|
2093
|
-
if not b_chunk:
|
|
2096
|
+
if not b_chunk and b_chunk is not None:
|
|
2094
2097
|
selector.unregister(key.fileobj)
|
|
2095
2098
|
elif key.fileobj == cmd.stdout:
|
|
2096
2099
|
stdout += b_chunk
|
|
@@ -2185,6 +2188,18 @@ def get_module_path():
|
|
|
2185
2188
|
return os.path.dirname(os.path.realpath(__file__))
|
|
2186
2189
|
|
|
2187
2190
|
|
|
2191
|
+
_mini_six = {
|
|
2192
|
+
"b": lambda s: s.encode("latin-1"),
|
|
2193
|
+
"PY2": False,
|
|
2194
|
+
"PY3": True,
|
|
2195
|
+
"text_type": str,
|
|
2196
|
+
"binary_type": bytes,
|
|
2197
|
+
"string_types": (str,),
|
|
2198
|
+
"integer_types": (int,),
|
|
2199
|
+
"iteritems": lambda d, **kw: iter(d.items(**kw)),
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
|
|
2188
2203
|
def __getattr__(importable_name):
|
|
2189
2204
|
"""Inject import-time deprecation warnings."""
|
|
2190
2205
|
if importable_name == 'datetime':
|
|
@@ -2202,24 +2217,12 @@ def __getattr__(importable_name):
|
|
|
2202
2217
|
elif importable_name == 'repeat':
|
|
2203
2218
|
from itertools import repeat
|
|
2204
2219
|
importable = repeat
|
|
2205
|
-
elif importable_name in {
|
|
2206
|
-
'PY2', 'PY3', 'b', 'binary_type', 'integer_types',
|
|
2207
|
-
'iteritems', 'string_types', 'text_type',
|
|
2208
|
-
}:
|
|
2209
|
-
import importlib
|
|
2210
|
-
importable = getattr(
|
|
2211
|
-
importlib.import_module('ansible.module_utils.six'),
|
|
2212
|
-
importable_name
|
|
2213
|
-
)
|
|
2214
2220
|
elif importable_name == 'map':
|
|
2215
2221
|
importable = map
|
|
2216
2222
|
elif importable_name == 'shlex_quote':
|
|
2217
2223
|
importable = shlex.quote
|
|
2218
|
-
|
|
2219
|
-
raise AttributeError(
|
|
2220
|
-
f'cannot import name {importable_name !r} '
|
|
2221
|
-
f"from '{__name__}' ({__file__ !s})"
|
|
2222
|
-
)
|
|
2224
|
+
elif (importable := _mini_six.get(importable_name, ...)) is ...:
|
|
2225
|
+
raise AttributeError(f"module {__name__!r} has no attribute {importable_name!r}")
|
|
2223
2226
|
|
|
2224
2227
|
deprecate(
|
|
2225
2228
|
msg=f"Importing '{importable_name}' from '{__name__}' is deprecated.",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
|
3
3
|
"""Collections ABC import shim.
|
|
4
4
|
|
|
5
|
-
Use `
|
|
5
|
+
Use `collections.abc` instead.
|
|
6
6
|
This module exists only for backwards compatibility.
|
|
7
7
|
"""
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
# Although this was originally intended for internal use only, it has wide adoption in collections.
|
|
12
12
|
# This is due in part to sanity tests previously recommending its use over `collections` imports.
|
|
13
|
-
from
|
|
13
|
+
from collections.abc import ( # pylint: disable=unused-import
|
|
14
14
|
MappingView,
|
|
15
15
|
ItemsView,
|
|
16
16
|
KeysView,
|
|
@@ -25,3 +25,12 @@ from ansible.module_utils.six.moves.collections_abc import ( # pylint: disable=
|
|
|
25
25
|
Iterable,
|
|
26
26
|
Iterator,
|
|
27
27
|
)
|
|
28
|
+
|
|
29
|
+
from ansible.module_utils.common import warnings as _warnings
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
_warnings.deprecate(
|
|
33
|
+
msg="The `ansible.module_utils.common._collections_compat` module is deprecated.",
|
|
34
|
+
help_text="Use `collections.abc` from the Python standard library instead.",
|
|
35
|
+
version="2.24",
|
|
36
|
+
)
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
from collections.abc import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import
|
|
10
|
+
|
|
11
|
+
from ansible.module_utils._internal import _no_six
|
|
9
12
|
from ansible.module_utils.common import warnings as _warnings
|
|
10
|
-
from ansible.module_utils.six import binary_type, text_type
|
|
11
|
-
from ansible.module_utils.six.moves.collections_abc import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ImmutableDict(Hashable, Mapping):
|
|
@@ -67,7 +68,7 @@ class ImmutableDict(Hashable, Mapping):
|
|
|
67
68
|
|
|
68
69
|
def is_string(seq):
|
|
69
70
|
"""Identify whether the input has a string-like type (including bytes)."""
|
|
70
|
-
return isinstance(seq, (
|
|
71
|
+
return isinstance(seq, (str, bytes))
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
def is_iterable(seq, include_strings=False):
|
|
@@ -114,3 +115,7 @@ def count(seq):
|
|
|
114
115
|
for elem in seq:
|
|
115
116
|
counters[elem] = counters.get(elem, 0) + 1
|
|
116
117
|
return counters
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def __getattr__(importable_name):
|
|
121
|
+
return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type")
|
|
@@ -7,10 +7,9 @@ from __future__ import annotations
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
import re
|
|
10
|
+
from collections.abc import MutableMapping
|
|
10
11
|
from copy import deepcopy
|
|
11
12
|
|
|
12
|
-
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
|
13
|
-
|
|
14
13
|
|
|
15
14
|
def camel_dict_to_snake_dict(camel_dict, reversible=False, ignore_list=()):
|
|
16
15
|
"""
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import re
|
|
9
|
+
|
|
10
|
+
# backward compat
|
|
11
|
+
from builtins import zip # pylint: disable=unused-import
|
|
12
|
+
|
|
9
13
|
from struct import pack
|
|
10
14
|
from socket import inet_ntoa
|
|
11
15
|
|
|
12
|
-
from ansible.module_utils.six.moves import zip
|
|
13
|
-
|
|
14
16
|
|
|
15
17
|
VALID_MASKS = [2**8 - 2**i for i in range(0, 9)]
|
|
16
18
|
|
|
@@ -9,9 +9,19 @@ import os
|
|
|
9
9
|
import typing as t
|
|
10
10
|
|
|
11
11
|
from collections import deque
|
|
12
|
-
from
|
|
12
|
+
from collections.abc import (
|
|
13
|
+
KeysView,
|
|
14
|
+
Set,
|
|
15
|
+
Sequence,
|
|
16
|
+
Mapping,
|
|
17
|
+
MutableMapping,
|
|
18
|
+
MutableSet,
|
|
19
|
+
MutableSequence,
|
|
20
|
+
)
|
|
21
|
+
from itertools import chain # pylint: disable=unused-import
|
|
13
22
|
|
|
14
23
|
from ansible.module_utils.common.collections import is_iterable
|
|
24
|
+
from ansible.module_utils._internal import _no_six
|
|
15
25
|
from ansible.module_utils._internal._datatag import AnsibleSerializable, AnsibleTagHelper
|
|
16
26
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
|
17
27
|
from ansible.module_utils.common.warnings import warn
|
|
@@ -33,26 +43,6 @@ from ansible.module_utils.errors import (
|
|
|
33
43
|
SubParameterTypeError,
|
|
34
44
|
)
|
|
35
45
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
|
36
|
-
|
|
37
|
-
from ansible.module_utils.six.moves.collections_abc import (
|
|
38
|
-
KeysView,
|
|
39
|
-
Set,
|
|
40
|
-
Sequence,
|
|
41
|
-
Mapping,
|
|
42
|
-
MutableMapping,
|
|
43
|
-
MutableSet,
|
|
44
|
-
MutableSequence,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
from ansible.module_utils.six import (
|
|
48
|
-
binary_type,
|
|
49
|
-
integer_types,
|
|
50
|
-
string_types,
|
|
51
|
-
text_type,
|
|
52
|
-
PY2,
|
|
53
|
-
PY3,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
46
|
from ansible.module_utils.common.validation import (
|
|
57
47
|
check_mutually_exclusive,
|
|
58
48
|
check_required_arguments,
|
|
@@ -243,7 +233,7 @@ def _handle_aliases(argument_spec, parameters, alias_warnings=None, alias_deprec
|
|
|
243
233
|
if aliases is None:
|
|
244
234
|
continue
|
|
245
235
|
|
|
246
|
-
if not is_iterable(aliases) or isinstance(aliases, (
|
|
236
|
+
if not is_iterable(aliases) or isinstance(aliases, (bytes, str)):
|
|
247
237
|
raise TypeError('internal error: aliases must be a list or tuple')
|
|
248
238
|
|
|
249
239
|
for alias in aliases:
|
|
@@ -346,7 +336,7 @@ def _list_no_log_values(argument_spec, params):
|
|
|
346
336
|
for sub_param in sub_parameters:
|
|
347
337
|
# Validate dict fields in case they came in as strings
|
|
348
338
|
|
|
349
|
-
if isinstance(sub_param,
|
|
339
|
+
if isinstance(sub_param, str):
|
|
350
340
|
sub_param = check_type_dict(sub_param)
|
|
351
341
|
|
|
352
342
|
if not isinstance(sub_param, Mapping):
|
|
@@ -362,7 +352,7 @@ def _return_datastructure_name(obj):
|
|
|
362
352
|
""" Return native stringified values from datastructures.
|
|
363
353
|
|
|
364
354
|
For use with removing sensitive values pre-jsonification."""
|
|
365
|
-
if isinstance(obj, (
|
|
355
|
+
if isinstance(obj, (str, bytes)):
|
|
366
356
|
if obj:
|
|
367
357
|
yield to_native(obj, errors='surrogate_or_strict')
|
|
368
358
|
return
|
|
@@ -375,7 +365,7 @@ def _return_datastructure_name(obj):
|
|
|
375
365
|
elif obj is None or isinstance(obj, bool):
|
|
376
366
|
# This must come before int because bools are also ints
|
|
377
367
|
return
|
|
378
|
-
elif isinstance(obj,
|
|
368
|
+
elif isinstance(obj, (int, float)):
|
|
379
369
|
yield to_native(obj, nonstring='simplerepr')
|
|
380
370
|
else:
|
|
381
371
|
raise TypeError('Unknown parameter type: %s' % (type(obj)))
|
|
@@ -413,26 +403,23 @@ def _remove_values_conditions(value, no_log_strings, deferred_removals):
|
|
|
413
403
|
"""
|
|
414
404
|
original_value = value
|
|
415
405
|
|
|
416
|
-
if isinstance(value, (
|
|
406
|
+
if isinstance(value, (str, bytes)):
|
|
417
407
|
# Need native str type
|
|
418
408
|
native_str_value = value
|
|
419
|
-
if isinstance(value,
|
|
409
|
+
if isinstance(value, str):
|
|
420
410
|
value_is_text = True
|
|
421
|
-
|
|
422
|
-
native_str_value = to_bytes(value, errors='surrogate_or_strict')
|
|
423
|
-
elif isinstance(value, binary_type):
|
|
411
|
+
elif isinstance(value, bytes):
|
|
424
412
|
value_is_text = False
|
|
425
|
-
|
|
426
|
-
native_str_value = to_text(value, errors='surrogate_or_strict')
|
|
413
|
+
native_str_value = to_text(value, errors='surrogate_or_strict')
|
|
427
414
|
|
|
428
415
|
if native_str_value in no_log_strings:
|
|
429
416
|
return 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
|
|
430
417
|
for omit_me in no_log_strings:
|
|
431
418
|
native_str_value = native_str_value.replace(omit_me, '*' * 8)
|
|
432
419
|
|
|
433
|
-
if value_is_text and isinstance(native_str_value,
|
|
420
|
+
if value_is_text and isinstance(native_str_value, bytes):
|
|
434
421
|
value = to_text(native_str_value, encoding='utf-8', errors='surrogate_then_replace')
|
|
435
|
-
elif not value_is_text and isinstance(native_str_value,
|
|
422
|
+
elif not value_is_text and isinstance(native_str_value, str):
|
|
436
423
|
value = to_bytes(native_str_value, encoding='utf-8', errors='surrogate_then_replace')
|
|
437
424
|
else:
|
|
438
425
|
value = native_str_value
|
|
@@ -514,7 +501,7 @@ def _set_defaults(argument_spec, parameters, set_default=True):
|
|
|
514
501
|
|
|
515
502
|
def _sanitize_keys_conditions(value, no_log_strings, ignore_keys, deferred_removals):
|
|
516
503
|
""" Helper method to :func:`sanitize_keys` to build ``deferred_removals`` and avoid deep recursion. """
|
|
517
|
-
if isinstance(value, (
|
|
504
|
+
if isinstance(value, (str, bytes)):
|
|
518
505
|
return value
|
|
519
506
|
|
|
520
507
|
if isinstance(value, Sequence):
|
|
@@ -541,7 +528,7 @@ def _sanitize_keys_conditions(value, no_log_strings, ignore_keys, deferred_remov
|
|
|
541
528
|
deferred_removals.append((value, new_value))
|
|
542
529
|
return new_value
|
|
543
530
|
|
|
544
|
-
if isinstance(value,
|
|
531
|
+
if isinstance(value, (int, float, bool, NoneType)):
|
|
545
532
|
return value
|
|
546
533
|
|
|
547
534
|
if isinstance(value, (datetime.datetime, datetime.date, datetime.time)):
|
|
@@ -560,8 +547,8 @@ def _validate_elements(wanted_type, parameter, values, options_context=None, err
|
|
|
560
547
|
# Get param name for strings so we can later display this value in a useful error message if needed
|
|
561
548
|
# Only pass 'kwargs' to our checkers and ignore custom callable checkers
|
|
562
549
|
kwargs = {}
|
|
563
|
-
if wanted_element_type == 'str' and isinstance(wanted_type,
|
|
564
|
-
if isinstance(parameter,
|
|
550
|
+
if wanted_element_type == 'str' and isinstance(wanted_type, str):
|
|
551
|
+
if isinstance(parameter, str):
|
|
565
552
|
kwargs['param'] = parameter
|
|
566
553
|
elif isinstance(parameter, dict):
|
|
567
554
|
kwargs['param'] = list(parameter.keys())[0]
|
|
@@ -620,7 +607,7 @@ def _validate_argument_types(argument_spec, parameters, prefix='', options_conte
|
|
|
620
607
|
# Get param name for strings so we can later display this value in a useful error message if needed
|
|
621
608
|
# Only pass 'kwargs' to our checkers and ignore custom callable checkers
|
|
622
609
|
kwargs = {}
|
|
623
|
-
if wanted_name == 'str' and isinstance(wanted_type,
|
|
610
|
+
if wanted_name == 'str' and isinstance(wanted_type, str):
|
|
624
611
|
kwargs['param'] = list(parameters.keys())[0]
|
|
625
612
|
|
|
626
613
|
# Get the name of the parent key if this is a nested option
|
|
@@ -659,7 +646,7 @@ def _validate_argument_values(argument_spec, parameters, options_context=None, e
|
|
|
659
646
|
if choices is None:
|
|
660
647
|
continue
|
|
661
648
|
|
|
662
|
-
if isinstance(choices, (frozenset, KeysView, Sequence)) and not isinstance(choices, (
|
|
649
|
+
if isinstance(choices, (frozenset, KeysView, Sequence)) and not isinstance(choices, (bytes, str)):
|
|
663
650
|
if param in parameters:
|
|
664
651
|
# Allow one or more when type='list' param with choices
|
|
665
652
|
if isinstance(parameters[param], list):
|
|
@@ -745,7 +732,7 @@ def _validate_sub_spec(
|
|
|
745
732
|
options_context.append(param)
|
|
746
733
|
|
|
747
734
|
# Make sure we can iterate over the elements
|
|
748
|
-
if not isinstance(parameters[param], Sequence) or isinstance(parameters[param],
|
|
735
|
+
if not isinstance(parameters[param], Sequence) or isinstance(parameters[param], str):
|
|
749
736
|
elements = [parameters[param]]
|
|
750
737
|
else:
|
|
751
738
|
elements = parameters[param]
|
|
@@ -940,3 +927,7 @@ def remove_values(value, no_log_strings):
|
|
|
940
927
|
raise TypeError('Unknown container type encountered when removing private values from output')
|
|
941
928
|
|
|
942
929
|
return new_value
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
def __getattr__(importable_name):
|
|
933
|
+
return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type", "integer_types", "string_types", "PY2", "PY3")
|