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.

Files changed (202) hide show
  1. ansible/_internal/__init__.py +1 -4
  2. ansible/_internal/_ansiballz/_builder.py +1 -3
  3. ansible/_internal/_collection_proxy.py +7 -9
  4. ansible/_internal/_display_utils.py +145 -0
  5. ansible/_internal/_json/__init__.py +3 -4
  6. ansible/_internal/_templating/_engine.py +1 -1
  7. ansible/_internal/_templating/_jinja_plugins.py +1 -2
  8. ansible/_internal/_wrapt.py +105 -301
  9. ansible/cli/__init__.py +11 -10
  10. ansible/cli/adhoc.py +1 -2
  11. ansible/cli/arguments/option_helpers.py +1 -1
  12. ansible/cli/config.py +5 -6
  13. ansible/cli/doc.py +67 -67
  14. ansible/cli/galaxy.py +15 -24
  15. ansible/cli/inventory.py +0 -1
  16. ansible/cli/playbook.py +0 -1
  17. ansible/cli/pull.py +0 -1
  18. ansible/cli/scripts/ansible_connection_cli_stub.py +1 -1
  19. ansible/config/base.yml +1 -25
  20. ansible/config/manager.py +0 -2
  21. ansible/executor/play_iterator.py +42 -20
  22. ansible/executor/playbook_executor.py +0 -9
  23. ansible/executor/powershell/async_watchdog.ps1 +24 -4
  24. ansible/executor/task_executor.py +32 -22
  25. ansible/executor/task_queue_manager.py +1 -3
  26. ansible/galaxy/api.py +33 -80
  27. ansible/galaxy/collection/__init__.py +4 -17
  28. ansible/galaxy/dependency_resolution/dataclasses.py +0 -10
  29. ansible/galaxy/dependency_resolution/providers.py +1 -2
  30. ansible/galaxy/role.py +1 -33
  31. ansible/inventory/manager.py +2 -3
  32. ansible/keyword_desc.yml +0 -3
  33. ansible/module_utils/_internal/_datatag/__init__.py +2 -10
  34. ansible/module_utils/_internal/_no_six.py +86 -0
  35. ansible/module_utils/_text.py +28 -8
  36. ansible/module_utils/ansible_release.py +2 -2
  37. ansible/module_utils/basic.py +27 -24
  38. ansible/module_utils/common/_collections_compat.py +11 -2
  39. ansible/module_utils/common/collections.py +8 -3
  40. ansible/module_utils/common/dict_transformations.py +1 -2
  41. ansible/module_utils/common/network.py +4 -2
  42. ansible/module_utils/common/parameters.py +32 -41
  43. ansible/module_utils/common/text/converters.py +109 -23
  44. ansible/module_utils/common/text/formatters.py +6 -2
  45. ansible/module_utils/common/validation.py +11 -9
  46. ansible/module_utils/connection.py +8 -3
  47. ansible/module_utils/facts/hardware/linux.py +23 -7
  48. ansible/module_utils/facts/hardware/netbsd.py +1 -1
  49. ansible/module_utils/facts/hardware/sunos.py +2 -1
  50. ansible/module_utils/facts/packages.py +6 -2
  51. ansible/module_utils/facts/system/distribution.py +2 -1
  52. ansible/module_utils/facts/system/env.py +6 -3
  53. ansible/module_utils/facts/system/local.py +3 -1
  54. ansible/module_utils/parsing/convert_bool.py +6 -2
  55. ansible/module_utils/service.py +2 -3
  56. ansible/module_utils/six/__init__.py +11 -6
  57. ansible/module_utils/urls.py +6 -2
  58. ansible/module_utils/yumdnf.py +0 -5
  59. ansible/modules/apt.py +18 -13
  60. ansible/modules/apt_repository.py +1 -1
  61. ansible/modules/assemble.py +5 -9
  62. ansible/modules/blockinfile.py +39 -23
  63. ansible/modules/cron.py +26 -35
  64. ansible/modules/deb822_repository.py +83 -12
  65. ansible/modules/dnf.py +3 -7
  66. ansible/modules/dnf5.py +4 -6
  67. ansible/modules/expect.py +0 -3
  68. ansible/modules/find.py +1 -2
  69. ansible/modules/get_url.py +1 -1
  70. ansible/modules/git.py +4 -5
  71. ansible/modules/include_vars.py +1 -1
  72. ansible/modules/lineinfile.py +71 -63
  73. ansible/modules/package_facts.py +1 -1
  74. ansible/modules/pip.py +8 -2
  75. ansible/modules/replace.py +6 -6
  76. ansible/modules/service.py +3 -4
  77. ansible/modules/stat.py +20 -0
  78. ansible/modules/uri.py +9 -10
  79. ansible/modules/user.py +1 -2
  80. ansible/modules/wait_for.py +2 -2
  81. ansible/modules/wait_for_connection.py +2 -1
  82. ansible/modules/yum_repository.py +1 -16
  83. ansible/parsing/dataloader.py +24 -31
  84. ansible/parsing/mod_args.py +3 -0
  85. ansible/parsing/vault/__init__.py +1 -2
  86. ansible/playbook/base.py +8 -56
  87. ansible/playbook/block.py +0 -60
  88. ansible/playbook/collectionsearch.py +1 -2
  89. ansible/playbook/handler.py +1 -7
  90. ansible/playbook/helpers.py +0 -7
  91. ansible/playbook/included_file.py +1 -1
  92. ansible/playbook/play.py +103 -37
  93. ansible/playbook/play_context.py +4 -0
  94. ansible/playbook/role/__init__.py +10 -65
  95. ansible/playbook/role/definition.py +3 -4
  96. ansible/playbook/role/include.py +2 -3
  97. ansible/playbook/role/metadata.py +1 -12
  98. ansible/playbook/role/requirement.py +1 -2
  99. ansible/playbook/role_include.py +1 -2
  100. ansible/playbook/taggable.py +16 -5
  101. ansible/playbook/task.py +51 -55
  102. ansible/plugins/action/__init__.py +20 -19
  103. ansible/plugins/action/add_host.py +1 -2
  104. ansible/plugins/action/fetch.py +2 -4
  105. ansible/plugins/action/group_by.py +1 -2
  106. ansible/plugins/action/include_vars.py +20 -22
  107. ansible/plugins/action/script.py +1 -3
  108. ansible/plugins/action/template.py +1 -2
  109. ansible/plugins/action/uri.py +4 -2
  110. ansible/plugins/cache/__init__.py +1 -0
  111. ansible/plugins/callback/__init__.py +13 -6
  112. ansible/plugins/connection/__init__.py +3 -7
  113. ansible/plugins/connection/local.py +2 -3
  114. ansible/plugins/connection/psrp.py +0 -2
  115. ansible/plugins/connection/ssh.py +2 -7
  116. ansible/plugins/connection/winrm.py +0 -2
  117. ansible/plugins/doc_fragments/result_format_callback.py +15 -0
  118. ansible/plugins/filter/core.py +4 -5
  119. ansible/plugins/filter/encryption.py +3 -27
  120. ansible/plugins/filter/mathstuff.py +1 -2
  121. ansible/plugins/filter/to_nice_yaml.yml +31 -3
  122. ansible/plugins/filter/to_yaml.yml +29 -12
  123. ansible/plugins/inventory/__init__.py +1 -2
  124. ansible/plugins/inventory/script.py +2 -1
  125. ansible/plugins/inventory/toml.py +3 -6
  126. ansible/plugins/inventory/yaml.py +1 -2
  127. ansible/plugins/list.py +10 -3
  128. ansible/plugins/loader.py +6 -6
  129. ansible/plugins/lookup/password.py +1 -2
  130. ansible/plugins/lookup/subelements.py +2 -3
  131. ansible/plugins/lookup/url.py +1 -1
  132. ansible/plugins/lookup/varnames.py +1 -2
  133. ansible/plugins/shell/__init__.py +9 -4
  134. ansible/plugins/shell/powershell.py +8 -24
  135. ansible/plugins/strategy/__init__.py +6 -3
  136. ansible/plugins/test/core.py +4 -1
  137. ansible/plugins/test/regex.yml +18 -6
  138. ansible/release.py +2 -2
  139. ansible/template/__init__.py +3 -7
  140. ansible/utils/collection_loader/_collection_config.py +5 -0
  141. ansible/utils/collection_loader/_collection_finder.py +11 -14
  142. ansible/utils/context_objects.py +7 -4
  143. ansible/utils/display.py +28 -167
  144. ansible/utils/encrypt.py +0 -5
  145. ansible/utils/helpers.py +6 -2
  146. ansible/utils/jsonrpc.py +7 -3
  147. ansible/utils/plugin_docs.py +49 -38
  148. ansible/utils/ssh_functions.py +0 -19
  149. ansible/utils/unsafe_proxy.py +7 -7
  150. ansible/vars/clean.py +2 -3
  151. ansible/vars/manager.py +27 -20
  152. ansible/vars/plugins.py +1 -31
  153. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/METADATA +3 -3
  154. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/RECORD +200 -200
  155. ansible_test/_data/completion/docker.txt +7 -7
  156. ansible_test/_data/completion/network.txt +0 -1
  157. ansible_test/_data/completion/remote.txt +4 -4
  158. ansible_test/_data/requirements/ansible-test.txt +1 -1
  159. ansible_test/_data/requirements/sanity.changelog.txt +1 -1
  160. ansible_test/_data/requirements/sanity.pep8.txt +1 -1
  161. ansible_test/_data/requirements/sanity.pylint.txt +4 -4
  162. ansible_test/_internal/cache.py +2 -5
  163. ansible_test/_internal/cli/compat.py +1 -1
  164. ansible_test/_internal/commands/coverage/combine.py +1 -3
  165. ansible_test/_internal/commands/integration/__init__.py +3 -7
  166. ansible_test/_internal/commands/integration/cloud/httptester.py +1 -1
  167. ansible_test/_internal/commands/integration/coverage.py +1 -3
  168. ansible_test/_internal/commands/integration/filters.py +5 -10
  169. ansible_test/_internal/commands/sanity/validate_modules.py +1 -5
  170. ansible_test/_internal/commands/units/__init__.py +1 -13
  171. ansible_test/_internal/completion.py +2 -5
  172. ansible_test/_internal/config.py +2 -7
  173. ansible_test/_internal/coverage_util.py +1 -1
  174. ansible_test/_internal/delegation.py +2 -0
  175. ansible_test/_internal/docker_util.py +1 -1
  176. ansible_test/_internal/host_profiles.py +6 -11
  177. ansible_test/_internal/provider/__init__.py +2 -5
  178. ansible_test/_internal/provisioning.py +2 -5
  179. ansible_test/_internal/pypi_proxy.py +1 -1
  180. ansible_test/_internal/target.py +2 -6
  181. ansible_test/_internal/thread.py +1 -4
  182. ansible_test/_internal/util.py +9 -14
  183. ansible_test/_util/controller/sanity/code-smell/runtime-metadata.py +14 -19
  184. ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py +30 -27
  185. ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +31 -18
  186. ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py +1 -2
  187. ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py +59 -71
  188. ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py +1 -2
  189. ansible_test/_util/target/cli/ansible_test_cli_stub.py +4 -2
  190. ansible_test/_util/target/common/constants.py +2 -2
  191. ansible_test/_util/target/setup/bootstrap.sh +0 -6
  192. ansible/utils/py3compat.py +0 -27
  193. ansible_test/_data/pytest/config/legacy.ini +0 -4
  194. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/WHEEL +0 -0
  195. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/entry_points.txt +0 -0
  196. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/COPYING +0 -0
  197. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/Apache-License.txt +0 -0
  198. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/BSD-3-Clause.txt +0 -0
  199. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/MIT-license.txt +0 -0
  200. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/PSF-license.txt +0 -0
  201. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/licenses/licenses/simplified_bsd.txt +0 -0
  202. {ansible_core-2.19.2.dist-info → ansible_core-2.20.0b1.dist-info}/top_level.txt +0 -0
@@ -8,11 +8,8 @@ from __future__ import annotations
8
8
  import codecs
9
9
  import json
10
10
 
11
- from ansible.module_utils.six import (
12
- binary_type,
13
- iteritems,
14
- text_type,
15
- )
11
+ from ansible.module_utils.compat import typing as _t
12
+ from ansible.module_utils._internal import _no_six
16
13
 
17
14
  try:
18
15
  codecs.lookup_error('surrogateescape')
@@ -25,8 +22,54 @@ _COMPOSED_ERROR_HANDLERS = frozenset((None, 'surrogate_or_replace',
25
22
  'surrogate_or_strict',
26
23
  'surrogate_then_replace'))
27
24
 
25
+ _T = _t.TypeVar('_T')
28
26
 
29
- def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
27
+ _NonStringPassthru: _t.TypeAlias = _t.Literal['passthru']
28
+ _NonStringOther: _t.TypeAlias = _t.Literal['simplerepr', 'empty', 'strict']
29
+ _NonStringAll: _t.TypeAlias = _t.Union[_NonStringPassthru, _NonStringOther]
30
+
31
+
32
+ @_t.overload
33
+ def to_bytes(
34
+ obj: object,
35
+ encoding: str = 'utf-8',
36
+ errors: str | None = None,
37
+ ) -> bytes: ...
38
+
39
+
40
+ @_t.overload
41
+ def to_bytes(
42
+ obj: bytes | str,
43
+ encoding: str = 'utf-8',
44
+ errors: str | None = None,
45
+ nonstring: _NonStringPassthru = 'passthru',
46
+ ) -> bytes: ...
47
+
48
+
49
+ @_t.overload
50
+ def to_bytes(
51
+ obj: _T,
52
+ encoding: str = 'utf-8',
53
+ errors: str | None = None,
54
+ nonstring: _NonStringPassthru = 'passthru',
55
+ ) -> _T: ...
56
+
57
+
58
+ @_t.overload
59
+ def to_bytes(
60
+ obj: object,
61
+ encoding: str = 'utf-8',
62
+ errors: str | None = None,
63
+ nonstring: _NonStringOther = 'simplerepr',
64
+ ) -> bytes: ...
65
+
66
+
67
+ def to_bytes(
68
+ obj: _T,
69
+ encoding: str = 'utf-8',
70
+ errors: str | None = None,
71
+ nonstring: _NonStringAll = 'simplerepr'
72
+ ) -> _T | bytes:
30
73
  """Make sure that a string is a byte string
31
74
 
32
75
  :arg obj: An object to make sure is a byte string. In most cases this
@@ -84,13 +127,13 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
84
127
  string is valid in the specified encoding. If it's important that the
85
128
  byte string is in the specified encoding do::
86
129
 
87
- encoded_string = to_bytes(to_text(input_string, 'latin-1'), 'utf-8')
130
+ encoded_string = to_bytes(to_text(input_string, encoding='latin-1'), encoding='utf-8')
88
131
 
89
132
  .. version_changed:: 2.3
90
133
 
91
134
  Added the ``surrogate_then_replace`` error handler and made it the default error handler.
92
135
  """
93
- if isinstance(obj, binary_type):
136
+ if isinstance(obj, bytes):
94
137
  return obj
95
138
 
96
139
  # We're given a text string
@@ -104,7 +147,7 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
104
147
  else:
105
148
  errors = 'replace'
106
149
 
107
- if isinstance(obj, text_type):
150
+ if isinstance(obj, str):
108
151
  try:
109
152
  # Try this first as it's the fastest
110
153
  return obj.encode(encoding, errors)
@@ -129,21 +172,60 @@ def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
129
172
  value = repr(obj)
130
173
  except UnicodeError:
131
174
  # Giving up
132
- return to_bytes('')
175
+ return b''
133
176
  elif nonstring == 'passthru':
134
177
  return obj
135
178
  elif nonstring == 'empty':
136
- # python2.4 doesn't have b''
137
- return to_bytes('')
179
+ return b''
138
180
  elif nonstring == 'strict':
139
181
  raise TypeError('obj must be a string type')
140
182
  else:
141
183
  raise TypeError('Invalid value %s for to_bytes\' nonstring parameter' % nonstring)
142
184
 
143
- return to_bytes(value, encoding, errors)
185
+ return to_bytes(value, encoding=encoding, errors=errors)
144
186
 
145
187
 
146
- def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
188
+ @_t.overload
189
+ def to_text(
190
+ obj: object,
191
+ encoding: str = 'utf-8',
192
+ errors: str | None = None,
193
+ ) -> str: ...
194
+
195
+
196
+ @_t.overload
197
+ def to_text(
198
+ obj: str | bytes,
199
+ encoding: str = 'utf-8',
200
+ errors: str | None = None,
201
+ nonstring: _NonStringPassthru = 'passthru',
202
+ ) -> str: ...
203
+
204
+
205
+ @_t.overload
206
+ def to_text(
207
+ obj: _T,
208
+ encoding: str = 'utf-8',
209
+ errors: str | None = None,
210
+ nonstring: _NonStringPassthru = 'passthru',
211
+ ) -> _T: ...
212
+
213
+
214
+ @_t.overload
215
+ def to_text(
216
+ obj: object,
217
+ encoding: str = 'utf-8',
218
+ errors: str | None = None,
219
+ nonstring: _NonStringOther = 'simplerepr',
220
+ ) -> str: ...
221
+
222
+
223
+ def to_text(
224
+ obj: _T,
225
+ encoding: str = 'utf-8',
226
+ errors: str | None = None,
227
+ nonstring: _NonStringAll = 'simplerepr'
228
+ ) -> _T | str:
147
229
  """Make sure that a string is a text string
148
230
 
149
231
  :arg obj: An object to make sure is a text string. In most cases this
@@ -194,7 +276,7 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
194
276
 
195
277
  Added the surrogate_then_replace error handler and made it the default error handler.
196
278
  """
197
- if isinstance(obj, text_type):
279
+ if isinstance(obj, str):
198
280
  return obj
199
281
 
200
282
  if errors in _COMPOSED_ERROR_HANDLERS:
@@ -205,7 +287,7 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
205
287
  else:
206
288
  errors = 'replace'
207
289
 
208
- if isinstance(obj, binary_type):
290
+ if isinstance(obj, bytes):
209
291
  # Note: We don't need special handling for surrogate_then_replace
210
292
  # because all bytes will either be made into surrogates or are valid
211
293
  # to decode.
@@ -221,17 +303,17 @@ def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'):
221
303
  value = repr(obj)
222
304
  except UnicodeError:
223
305
  # Giving up
224
- return u''
306
+ return ''
225
307
  elif nonstring == 'passthru':
226
308
  return obj
227
309
  elif nonstring == 'empty':
228
- return u''
310
+ return ''
229
311
  elif nonstring == 'strict':
230
312
  raise TypeError('obj must be a string type')
231
313
  else:
232
314
  raise TypeError('Invalid value %s for to_text\'s nonstring parameter' % nonstring)
233
315
 
234
- return to_text(value, encoding, errors)
316
+ return to_text(value, encoding=encoding, errors=errors)
235
317
 
236
318
 
237
319
  to_native = to_text
@@ -259,10 +341,10 @@ def container_to_bytes(d, encoding='utf-8', errors='surrogate_or_strict'):
259
341
  """
260
342
  # DTFIX-FUTURE: deprecate
261
343
 
262
- if isinstance(d, text_type):
344
+ if isinstance(d, str):
263
345
  return to_bytes(d, encoding=encoding, errors=errors)
264
346
  elif isinstance(d, dict):
265
- return dict(container_to_bytes(o, encoding, errors) for o in iteritems(d))
347
+ return dict(container_to_bytes(o, encoding, errors) for o in d.items())
266
348
  elif isinstance(d, list):
267
349
  return [container_to_bytes(o, encoding, errors) for o in d]
268
350
  elif isinstance(d, tuple):
@@ -279,14 +361,18 @@ def container_to_text(d, encoding='utf-8', errors='surrogate_or_strict'):
279
361
  """
280
362
  # DTFIX-FUTURE: deprecate
281
363
 
282
- if isinstance(d, binary_type):
364
+ if isinstance(d, bytes):
283
365
  # Warning, can traceback
284
366
  return to_text(d, encoding=encoding, errors=errors)
285
367
  elif isinstance(d, dict):
286
- return dict(container_to_text(o, encoding, errors) for o in iteritems(d))
368
+ return dict(container_to_text(o, encoding, errors) for o in d.items())
287
369
  elif isinstance(d, list):
288
370
  return [container_to_text(o, encoding, errors) for o in d]
289
371
  elif isinstance(d, tuple):
290
372
  return tuple(container_to_text(o, encoding, errors) for o in d)
291
373
  else:
292
374
  return d
375
+
376
+
377
+ def __getattr__(importable_name):
378
+ return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type", "iteritems")
@@ -6,7 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  import re
8
8
 
9
- from ansible.module_utils.six import iteritems
9
+ from ansible.module_utils._internal import _no_six
10
10
 
11
11
  SIZE_RANGES = {
12
12
  'Y': 1 << 80,
@@ -117,7 +117,7 @@ def bytes_to_human(size, isbits=False, unit=None):
117
117
  base = 'bits'
118
118
  suffix = ''
119
119
 
120
- for suffix, limit in sorted(iteritems(SIZE_RANGES), key=lambda item: -item[1]):
120
+ for suffix, limit in sorted(SIZE_RANGES.items(), key=lambda item: -item[1]):
121
121
  if (unit is None and size >= limit) or unit is not None and unit.upper() == suffix[0]:
122
122
  break
123
123
 
@@ -127,3 +127,7 @@ def bytes_to_human(size, isbits=False, unit=None):
127
127
  suffix = base
128
128
 
129
129
  return '%.2f %s' % (size / limit, suffix)
130
+
131
+
132
+ def __getattr__(importable_name):
133
+ return _no_six.deprecate(importable_name, __name__, "iteritems")
@@ -10,15 +10,13 @@ import os
10
10
  import re
11
11
 
12
12
  from ast import literal_eval
13
+ from ansible.module_utils._internal import _no_six
13
14
  from ansible.module_utils.common import json as _common_json
14
15
  from ansible.module_utils.common.text.converters import to_native
15
16
  from ansible.module_utils.common.collections import is_iterable
16
17
  from ansible.module_utils.common.text.formatters import human_to_bytes
17
18
  from ansible.module_utils.common.warnings import deprecate
18
19
  from ansible.module_utils.parsing.convert_bool import boolean
19
- from ansible.module_utils.six import (
20
- string_types,
21
- )
22
20
 
23
21
 
24
22
  def count_terms(terms, parameters):
@@ -43,7 +41,7 @@ def safe_eval(value, locals=None, include_exceptions=False):
43
41
  version="2.21",
44
42
  )
45
43
  # do not allow method calls to modules
46
- if not isinstance(value, string_types):
44
+ if not isinstance(value, str):
47
45
  # already templated to a datavaluestructure, perhaps?
48
46
  if include_exceptions:
49
47
  return (value, None)
@@ -194,7 +192,7 @@ def check_required_by(requirements, parameters, options_context=None):
194
192
  if key not in parameters or parameters[key] is None:
195
193
  continue
196
194
  # Support strings (single-item lists)
197
- if isinstance(value, string_types):
195
+ if isinstance(value, str):
198
196
  value = [value]
199
197
 
200
198
  if missing := [required for required in value if required not in parameters or parameters[required] is None]:
@@ -373,7 +371,7 @@ def check_type_str(value, allow_conversion=True, param=None, prefix=''):
373
371
  :returns: Original value if it is a string, the value converted to a string
374
372
  if allow_conversion=True, or raises a TypeError if allow_conversion=False.
375
373
  """
376
- if isinstance(value, string_types):
374
+ if isinstance(value, str):
377
375
  return value
378
376
 
379
377
  if value is None:
@@ -406,7 +404,7 @@ def check_type_list(value):
406
404
  return value
407
405
 
408
406
  # DTFIX-FUTURE: deprecate legacy comma split functionality, eventually replace with `_check_type_list_strict`
409
- if isinstance(value, string_types):
407
+ if isinstance(value, str):
410
408
  return value.split(",")
411
409
  elif isinstance(value, int) or isinstance(value, float):
412
410
  return [str(value)]
@@ -434,7 +432,7 @@ def check_type_dict(value):
434
432
  if isinstance(value, dict):
435
433
  return value
436
434
 
437
- if isinstance(value, string_types):
435
+ if isinstance(value, str):
438
436
  if value.startswith("{"):
439
437
  try:
440
438
  return json.loads(value)
@@ -497,7 +495,7 @@ def check_type_bool(value):
497
495
  if isinstance(value, bool):
498
496
  return value
499
497
 
500
- if isinstance(value, string_types) or isinstance(value, (int, float)):
498
+ if isinstance(value, str) or isinstance(value, (int, float)):
501
499
  return boolean(value)
502
500
 
503
501
  raise TypeError('%s cannot be converted to a bool' % type(value))
@@ -597,3 +595,7 @@ def check_type_jsonarg(value):
597
595
  return json.dumps(value, cls=_common_json._get_legacy_encoder(), _decode_bytes=True)
598
596
 
599
597
  raise TypeError('%s cannot be converted to a json string' % type(value))
598
+
599
+
600
+ def __getattr__(importable_name):
601
+ return _no_six.deprecate(importable_name, __name__, "string_types")
@@ -36,9 +36,10 @@ import struct
36
36
  import uuid
37
37
 
38
38
  from functools import partial
39
+
40
+ from ansible.module_utils._internal import _no_six
39
41
  from ansible.module_utils.common.text.converters import to_bytes, to_text
40
42
  from ansible.module_utils.common.json import _get_legacy_encoder
41
- from ansible.module_utils.six import iteritems
42
43
 
43
44
 
44
45
  def write_to_stream(stream, obj):
@@ -95,7 +96,7 @@ class ConnectionError(Exception):
95
96
 
96
97
  def __init__(self, message, *args, **kwargs):
97
98
  super(ConnectionError, self).__init__(message)
98
- for k, v in iteritems(kwargs):
99
+ for k, v in kwargs.items():
99
100
  setattr(self, k, v)
100
101
 
101
102
 
@@ -149,7 +150,7 @@ class Connection(object):
149
150
  raise ConnectionError(
150
151
  "Unable to decode JSON from response to {0}. Received '{1}'.".format(name, out)
151
152
  )
152
- params = [repr(arg) for arg in args] + ['{0}={1!r}'.format(k, v) for k, v in iteritems(kwargs)]
153
+ params = [repr(arg) for arg in args] + ['{0}={1!r}'.format(k, v) for k, v in kwargs.items()]
153
154
  params = ', '.join(params)
154
155
  raise ConnectionError(
155
156
  "Unable to decode JSON from response to {0}({1}). Received '{2}'.".format(name, params, out)
@@ -200,3 +201,7 @@ class Connection(object):
200
201
  sf.close()
201
202
 
202
203
  return to_text(response, errors='surrogate_or_strict')
204
+
205
+
206
+ def __getattr__(importable_name):
207
+ return _no_six.deprecate(importable_name, __name__, "iteritems")
@@ -24,13 +24,13 @@ import re
24
24
  import sys
25
25
  import time
26
26
 
27
+ from ansible.module_utils._internal import _no_six
27
28
  from ansible.module_utils._internal._concurrent import _futures
28
29
  from ansible.module_utils.common.locale import get_best_parsable_locale
29
30
  from ansible.module_utils.common.text.converters import to_text
30
31
  from ansible.module_utils.common.text.formatters import bytes_to_human
31
32
  from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector
32
33
  from ansible.module_utils.facts.utils import get_file_content, get_file_lines, get_mount_size
33
- from ansible.module_utils.six import iteritems
34
34
 
35
35
  # import this as a module to ensure we get the same module instance
36
36
  from ansible.module_utils.facts import timeout
@@ -653,7 +653,7 @@ class LinuxHardware(Hardware):
653
653
  retval[target].add(entry)
654
654
  except OSError:
655
655
  continue
656
- return dict((k, list(sorted(v))) for (k, v) in iteritems(retval))
656
+ return dict((k, list(sorted(v))) for (k, v) in retval.items())
657
657
  except OSError:
658
658
  return {}
659
659
 
@@ -665,7 +665,7 @@ class LinuxHardware(Hardware):
665
665
  device = elements[3]
666
666
  target = elements[5]
667
667
  retval[target].add(device)
668
- return dict((k, list(sorted(v))) for (k, v) in iteritems(retval))
668
+ return dict((k, list(sorted(v))) for (k, v) in retval.items())
669
669
  except OSError:
670
670
  return {}
671
671
 
@@ -750,7 +750,7 @@ class LinuxHardware(Hardware):
750
750
  d = {}
751
751
  d['virtual'] = virtual
752
752
  d['links'] = {}
753
- for (link_type, link_values) in iteritems(links):
753
+ for (link_type, link_values) in links.items():
754
754
  d['links'][link_type] = link_values.get(block, [])
755
755
  diskname = os.path.basename(sysdir)
756
756
  for key in ['vendor', 'model', 'sas_address', 'sas_device_handle']:
@@ -801,7 +801,7 @@ class LinuxHardware(Hardware):
801
801
  part_sysdir = sysdir + "/" + partname
802
802
 
803
803
  part['links'] = {}
804
- for (link_type, link_values) in iteritems(links):
804
+ for (link_type, link_values) in links.items():
805
805
  part['links'][link_type] = link_values.get(partname, [])
806
806
 
807
807
  part['start'] = get_file_content(part_sysdir + "/start", 0)
@@ -890,7 +890,8 @@ class LinuxHardware(Hardware):
890
890
  'size_g': items[-2],
891
891
  'free_g': items[-1],
892
892
  'num_lvs': items[2],
893
- 'num_pvs': items[1]
893
+ 'num_pvs': items[1],
894
+ 'lvs': {},
894
895
  }
895
896
 
896
897
  lvs_path = self.module.get_bin_path('lvs')
@@ -901,7 +902,18 @@ class LinuxHardware(Hardware):
901
902
  rc, lv_lines, err = self.module.run_command('%s %s' % (lvs_path, lvm_util_options))
902
903
  for lv_line in lv_lines.splitlines():
903
904
  items = lv_line.strip().split(',')
904
- lvs[items[0]] = {'size_g': items[3], 'vg': items[1]}
905
+ vg_name = items[1]
906
+ lv_name = items[0]
907
+ # The LV name is only unique per VG, so the top level fact lvs can be misleading.
908
+ # TODO: deprecate lvs in favor of vgs
909
+ lvs[lv_name] = {'size_g': items[3], 'vg': vg_name}
910
+ try:
911
+ vgs[vg_name]['lvs'][lv_name] = {'size_g': items[3]}
912
+ except KeyError:
913
+ self.module.warn(
914
+ "An LVM volume group was created while gathering LVM facts, "
915
+ "and is not included in ansible_facts['vgs']."
916
+ )
905
917
 
906
918
  pvs_path = self.module.get_bin_path('pvs')
907
919
  # pvs fields: PV VG #Fmt #Attr PSize PFree
@@ -925,3 +937,7 @@ class LinuxHardwareCollector(HardwareCollector):
925
937
  _fact_class = LinuxHardware
926
938
 
927
939
  required_facts = set(['platform'])
940
+
941
+
942
+ def __getattr__(importable_name):
943
+ return _no_six.deprecate(importable_name, __name__, "iteritems")
@@ -19,7 +19,7 @@ import os
19
19
  import re
20
20
  import time
21
21
 
22
- from ansible.module_utils.six.moves import reduce
22
+ from functools import reduce
23
23
 
24
24
  from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector
25
25
  from ansible.module_utils.facts.timeout import TimeoutError, timeout
@@ -18,12 +18,13 @@ from __future__ import annotations
18
18
  import re
19
19
  import time
20
20
 
21
+ from functools import reduce
22
+
21
23
  from ansible.module_utils.common.locale import get_best_parsable_locale
22
24
  from ansible.module_utils.common.text.formatters import bytes_to_human
23
25
  from ansible.module_utils.facts.utils import get_file_content, get_mount_size
24
26
  from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector
25
27
  from ansible.module_utils.facts import timeout
26
- from ansible.module_utils.six.moves import reduce
27
28
 
28
29
 
29
30
  class SunOSHardware(Hardware):
@@ -7,7 +7,7 @@ import ansible.module_utils.compat.typing as t
7
7
 
8
8
  from abc import ABCMeta, abstractmethod
9
9
 
10
- from ansible.module_utils.six import with_metaclass
10
+ from ansible.module_utils._internal import _no_six
11
11
  from ansible.module_utils.basic import missing_required_lib
12
12
  from ansible.module_utils.common.process import get_bin_path
13
13
  from ansible.module_utils.common.respawn import has_respawned, probe_interpreters_for_module, respawn_module
@@ -19,7 +19,7 @@ def get_all_pkg_managers():
19
19
  return {obj.__name__.lower(): obj for obj in get_all_subclasses(PkgMgr) if obj not in (CLIMgr, LibMgr, RespawningLibMgr)}
20
20
 
21
21
 
22
- class PkgMgr(with_metaclass(ABCMeta, object)): # type: ignore[misc]
22
+ class PkgMgr(metaclass=ABCMeta):
23
23
 
24
24
  @abstractmethod
25
25
  def is_available(self, handle_exceptions):
@@ -125,3 +125,7 @@ class CLIMgr(PkgMgr):
125
125
  if not handle_exceptions:
126
126
  raise
127
127
  return found
128
+
129
+
130
+ def __getattr__(importable_name):
131
+ return _no_six.deprecate(importable_name, __name__, "with_metaclass")
@@ -529,7 +529,8 @@ class Distribution(object):
529
529
  'EuroLinux', 'Kylin Linux Advanced Server', 'MIRACLE'],
530
530
  'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon',
531
531
  'Linux Mint', 'SteamOS', 'Devuan', 'Kali', 'Cumulus Linux',
532
- 'Pop!_OS', 'Parrot', 'Pardus GNU/Linux', 'Uos', 'Deepin', 'OSMC', 'Linux Mint Debian Edition'],
532
+ 'Pop!_OS', 'Parrot', 'Pardus GNU/Linux', 'Uos', 'Deepin', 'OSMC',
533
+ 'Linux Mint Debian Edition', 'Univention Corporate Server'],
533
534
  'Suse': ['SuSE', 'SLES', 'SLED', 'openSUSE', 'openSUSE Tumbleweed',
534
535
  'SLES_SAP', 'SUSE_LINUX', 'openSUSE Leap', 'ALP-Dolomite', 'SL-Micro',
535
536
  'openSUSE MicroOS'],
@@ -18,8 +18,7 @@ from __future__ import annotations
18
18
  import os
19
19
  import typing as t
20
20
 
21
- from ansible.module_utils.six import iteritems
22
-
21
+ from ansible.module_utils._internal import _no_six
23
22
  from ansible.module_utils.facts.collector import BaseFactCollector
24
23
 
25
24
 
@@ -31,7 +30,11 @@ class EnvFactCollector(BaseFactCollector):
31
30
  env_facts = {}
32
31
  env_facts['env'] = {}
33
32
 
34
- for k, v in iteritems(os.environ):
33
+ for k, v in os.environ.items():
35
34
  env_facts['env'][k] = v
36
35
 
37
36
  return env_facts
37
+
38
+
39
+ def __getattr__(importable_name):
40
+ return _no_six.deprecate(importable_name, __name__, "iteritems")
@@ -3,16 +3,18 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
+ import configparser
6
7
  import glob
7
8
  import json
8
9
  import os
9
10
  import stat
10
11
  import typing as t
11
12
 
13
+ from io import StringIO
14
+
12
15
  from ansible.module_utils.common.text.converters import to_text
13
16
  from ansible.module_utils.facts.utils import get_file_content
14
17
  from ansible.module_utils.facts.collector import BaseFactCollector
15
- from ansible.module_utils.six.moves import configparser, StringIO
16
18
 
17
19
 
18
20
  class LocalFactCollector(BaseFactCollector):
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  import collections.abc as c
7
7
 
8
- from ansible.module_utils.six import binary_type, text_type
8
+ from ansible.module_utils._internal import _no_six
9
9
  from ansible.module_utils.common.text.converters import to_text
10
10
 
11
11
 
@@ -20,7 +20,7 @@ def boolean(value, strict=True):
20
20
 
21
21
  normalized_value = value
22
22
 
23
- if isinstance(value, (text_type, binary_type)):
23
+ if isinstance(value, (str, bytes)):
24
24
  normalized_value = to_text(value, errors='surrogate_or_strict').lower().strip()
25
25
 
26
26
  if not isinstance(value, c.Hashable):
@@ -32,3 +32,7 @@ def boolean(value, strict=True):
32
32
  return False
33
33
 
34
34
  raise TypeError("The value '%s' is not a valid boolean. Valid booleans include: %s" % (to_text(value), ', '.join(repr(i) for i in BOOLEANS)))
35
+
36
+
37
+ def __getattr__(importable_name):
38
+ return _no_six.deprecate(importable_name, __name__, "binary_type", "text_type")
@@ -36,7 +36,6 @@ import select
36
36
  import shlex
37
37
  import subprocess
38
38
 
39
- from ansible.module_utils.six import b
40
39
  from ansible.module_utils.common.text.converters import to_bytes, to_text
41
40
 
42
41
 
@@ -200,7 +199,7 @@ def daemonize(module, cmd):
200
199
  fds = [p.stdout, p.stderr]
201
200
 
202
201
  # loop reading output till it is done
203
- output = {p.stdout: b(""), p.stderr: b("")}
202
+ output = {p.stdout: b"", p.stderr: b""}
204
203
  while fds:
205
204
  rfd, wfd, efd = select.select(fds, [], fds, 1)
206
205
  if (rfd + wfd + efd) or p.poll() is None:
@@ -234,7 +233,7 @@ def daemonize(module, cmd):
234
233
  os.waitpid(pid, 0)
235
234
 
236
235
  # Grab response data after child finishes
237
- return_data = b("")
236
+ return_data = b""
238
237
  while True:
239
238
  rfd, wfd, efd = select.select([pipe[0]], [], [pipe[0]])
240
239
  if pipe[0] in rfd:
@@ -3,7 +3,7 @@
3
3
  # upstream vendored file that we're not going to modify on our own
4
4
  # pylint: disable=undefined-variable
5
5
  #
6
- # Copyright (c) 2010-2020 Benjamin Peterson
6
+ # Copyright (c) 2010-2024 Benjamin Peterson
7
7
  #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  # of this software and associated documentation files (the "Software"), to deal
@@ -35,10 +35,10 @@ import types
35
35
 
36
36
  # The following makes it easier for us to script updates of the bundled code. It is not part of
37
37
  # upstream six
38
- _BUNDLED_METADATA = {"pypi_name": "six", "version": "1.16.0"}
38
+ _BUNDLED_METADATA = {"pypi_name": "six", "version": "1.17.0"}
39
39
 
40
40
  __author__ = "Benjamin Peterson <benjamin@python.org>"
41
- __version__ = "1.16.0"
41
+ __version__ = "1.17.0"
42
42
 
43
43
 
44
44
  # Useful for very coarse version differentiation.
@@ -273,7 +273,7 @@ _moved_attributes = [
273
273
  MovedAttribute("reduce", "__builtin__", "functools"),
274
274
  MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
275
275
  MovedAttribute("StringIO", "StringIO", "io"),
276
- MovedAttribute("UserDict", "UserDict", "collections"),
276
+ MovedAttribute("UserDict", "UserDict", "collections", "IterableUserDict", "UserDict"),
277
277
  MovedAttribute("UserList", "UserList", "collections"),
278
278
  MovedAttribute("UserString", "UserString", "collections"),
279
279
  MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
@@ -445,12 +445,17 @@ _urllib_request_moved_attributes = [
445
445
  MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
446
446
  MovedAttribute("urlretrieve", "urllib", "urllib.request"),
447
447
  MovedAttribute("urlcleanup", "urllib", "urllib.request"),
448
- MovedAttribute("URLopener", "urllib", "urllib.request"),
449
- MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
450
448
  MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
451
449
  MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
452
450
  MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
453
451
  ]
452
+ if sys.version_info[:2] < (3, 14):
453
+ _urllib_request_moved_attributes.extend(
454
+ [
455
+ MovedAttribute("URLopener", "urllib", "urllib.request"),
456
+ MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
457
+ ]
458
+ )
454
459
  for attr in _urllib_request_moved_attributes:
455
460
  setattr(Module_six_moves_urllib_request, attr.name, attr)
456
461
  del attr