Skip to content

Commit 95ac4af

Browse files
committed
Remove compatibility code for older ansible-core versions.
1 parent cf5e97a commit 95ac4af

File tree

6 files changed

+8
-34
lines changed

6 files changed

+8
-34
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
removed_features:
22
- "Dropped support for ansible-core 2.15. The collection now requires ansible-core 2.16 or newer. This means that on the controller, Python 3.10+ is required. On the target side, Python 2.7 and Python 3.6+ are supported (https://github.com/ansible-collections/community.general/pull/10160)."
3+
minor_changes:
4+
- "cartesian lookup plugin - removed compatibility code for ansible-core < 2.14 (https://github.com/ansible-collections/community.general/pull/10160)."
5+
- "dependent lookup plugin - removed compatibility code for ansible-core < 2.14 (https://github.com/ansible-collections/community.general/pull/10160)."
6+
- "flattened lookup plugin - removed compatibility code for ansible-core < 2.14 (https://github.com/ansible-collections/community.general/pull/10160)."
7+
- "redfish module utils - removed compatibility code for ansible-core < 2.14 (https://github.com/ansible-collections/community.general/pull/10160)."

plugins/lookup/cartesian.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ def _lookup_variables(self, terms):
6666
"""
6767
results = []
6868
for x in terms:
69-
try:
70-
intermediate = listify_lookup_plugin_terms(x, templar=self._templar)
71-
except TypeError:
72-
# The loader argument is deprecated in ansible-core 2.14+. Fall back to
73-
# pre-2.14 behavior for older ansible-core versions.
74-
intermediate = listify_lookup_plugin_terms(x, templar=self._templar, loader=self._loader)
75-
results.append(intermediate)
69+
results.append(listify_lookup_plugin_terms(x, templar=self._templar))
7670
return results
7771

7872
def run(self, terms, variables=None, **kwargs):

plugins/lookup/dependent.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,13 @@
127127
from ansible.release import __version__ as ansible_version
128128
from ansible.template import Templar
129129

130-
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
131-
132130
try:
133131
from ansible.template import trust_as_template as _trust_as_template
134132
HAS_DATATAGGING = True
135133
except ImportError:
136134
HAS_DATATAGGING = False
137135

138136

139-
# Whether Templar has a cache, which can be controlled by Templar.template()'s cache option.
140-
# The cache was removed for ansible-core 2.14 (https://github.com/ansible/ansible/pull/78419)
141-
_TEMPLAR_HAS_TEMPLATE_CACHE = LooseVersion(ansible_version) < LooseVersion('2.14.0')
142-
143-
144137
def _make_safe(value):
145138
if HAS_DATATAGGING and isinstance(value, str):
146139
return _trust_as_template(value)
@@ -156,8 +149,6 @@ def __evaluate(self, expression, templar, variables):
156149
"""
157150
templar.available_variables = variables or {}
158151
quoted_expression = "{0}{1}{2}".format("{{", expression, "}}")
159-
if _TEMPLAR_HAS_TEMPLATE_CACHE:
160-
return templar.template(quoted_expression, cache=False)
161152
if hasattr(templar, 'evaluate_expression'):
162153
# This is available since the Data Tagging PR has been merged
163154
return templar.evaluate_expression(_make_safe(expression))

plugins/lookup/flattened.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ def _do_flatten(self, terms, variables):
6767

6868
if isinstance(term, string_types):
6969
# convert a variable to a list
70-
try:
71-
term2 = listify_lookup_plugin_terms(term, templar=self._templar)
72-
except TypeError:
73-
# The loader argument is deprecated in ansible-core 2.14+. Fall back to
74-
# pre-2.14 behavior for older ansible-core versions.
75-
term2 = listify_lookup_plugin_terms(term, templar=self._templar, loader=self._loader)
70+
term2 = listify_lookup_plugin_terms(term, templar=self._templar)
7671
# but avoid converting a plain string to a list of one string
7772
if term2 != [term]:
7873
term = term2

plugins/module_utils/redfish_utils.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import os
1111
import random
1212
import string
13-
import gzip
1413
import time
15-
from io import BytesIO
1614
from ansible.module_utils.urls import open_url
1715
from ansible.module_utils.common.text.converters import to_native
1816
from ansible.module_utils.common.text.converters import to_text
@@ -21,8 +19,6 @@
2119
from ansible.module_utils.six.moves import http_client
2220
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
2321
from ansible.module_utils.six.moves.urllib.parse import urlparse
24-
from ansible.module_utils.ansible_release import __version__ as ansible_version
25-
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
2622

2723
GET_HEADERS = {'accept': 'application/json', 'OData-Version': '4.0'}
2824
POST_HEADERS = {'content-type': 'application/json', 'accept': 'application/json',
@@ -183,12 +179,7 @@ def get_request(self, uri, override_headers=None, allow_no_resp=False, timeout=N
183179
timeout=timeout,
184180
)
185181
try:
186-
if headers.get('content-encoding') == 'gzip' and LooseVersion(ansible_version) < LooseVersion('2.14'):
187-
# Older versions of Ansible do not automatically decompress the data
188-
# Starting in 2.14, open_url will decompress the response data by default
189-
data = json.loads(to_native(gzip.open(BytesIO(resp.read()), 'rt', encoding='utf-8').read()))
190-
else:
191-
data = json.loads(to_native(resp.read()))
182+
data = json.loads(to_native(resp.read()))
192183
except Exception as e:
193184
# No response data; this is okay in certain cases
194185
data = None

plugins/modules/simpleinit_msb.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
version_added: 7.5.0
1818
description:
1919
- Controls services on remote hosts using C(simpleinit-msb).
20-
notes:
21-
- This module needs ansible-core 2.15.5 or newer. Older versions have a broken and insufficient daemonize functionality.
2220
author: "Vlad Glagolev (@vaygr)"
2321
extends_documentation_fragment:
2422
- community.general.attributes

0 commit comments

Comments
 (0)