Open
Description
Summary
The test_template
unit tests fail due to setting disable_lookups
to True, which is deprecated in ansible 2.19. I'll provide a minimal PR to fix this in a moment.
Issue Type
- Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 25.2.1 using ansible-core:2.19.0b2 ansible-compat:25.1.5 ruamel-yaml:0.18.10 ruamel-yaml-clib:0.2.12
WARNING Project directory /.ansible cannot be used for caching as it is not writable.
WARNING Using unique temporary directory /tmp/.ansible-0aaa for caching.
Debian trixie (13)
- ansible installation method: OS package
- ansible-lint installation method: OS package
STEPS TO REPRODUCE
Run current ansible-lint unit tests against ansible 2.19
[...]
============================================================================================================== FAILURES ===============================================================================================================
________________________________________________________________________________________________________ test_template[simple] ________________________________________________________________________________________________________
template = '{{ playbook_dir }}', output = '/a/b/c'
@pytest.mark.parametrize(
("template", "output"),
(
pytest.param("{{ playbook_dir }}", "/a/b/c", id="simple"),
# Does not work the same with ansible 2.19 with data tagging
# pytest.param(
# "{{ 'hello' | doesnotexist }}",
# "hello", # newer implementation ignores unknown filters
# id="unknown_filter",
# ),
pytest.param(
"{{ hello | to_json }}",
"{{ hello | to_json }}",
id="to_json_filter_on_undefined_variable",
),
pytest.param(
"{{ hello | to_nice_yaml }}",
"{{ hello | to_nice_yaml }}",
id="to_nice_yaml_filter_on_undefined_variable",
),
),
)
def test_template(template: str, output: str) -> None:
"""Verify that resolvable template vars and filters get rendered."""
> result = utils.template(
basedir=Path("/base/dir"),
value=template,
variables={"playbook_dir": "/a/b/c"},
fail_on_error=False,
)
test/test_utils.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/ansiblelint/utils.py:315: in template
value = ansible_template(
/usr/lib/python3/dist-packages/ansiblelint/utils.py:209: in ansible_template
templated = templar.template(varname, **kwargs) # type: ignore[no-untyped-call]
/usr/lib/python3/dist-packages/ansible/template/__init__.py:280: in template
_display.deprecated(
/usr/lib/python3/dist-packages/ansible/utils/display.py:678: in deprecated
self._deprecated_with_plugin_info(
/usr/lib/python3/dist-packages/ansible/utils/display.py:735: in _deprecated_with_plugin_info
self._deprecated(deprecation)
/usr/lib/python3/dist-packages/ansible/utils/display.py:388: in wrapper
return func(self, *args, **kwargs)
/usr/lib/python3/dist-packages/ansible/utils/display.py:747: in _deprecated
self.warning('Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ansible.utils.display.Display object at 0x7fc86d1657f0>, msg = 'Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.', formatted = False
def warning( # noqa: DOC103
self: Display, # noqa: ARG001
msg: str,
formatted: bool = False, # noqa: ARG001,FBT001,FBT002
*,
help_text: str | None = None, # noqa: ARG001
obj: Any = None, # noqa: ARG001,ANN401
) -> None: # pragma: no cover
"""Override ansible.utils.display.Display.warning to avoid printing warnings."""
> warnings.warn(
message=msg,
category=AnsibleWarning,
stacklevel=2,
source={"msg": msg},
)
E ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
/usr/lib/python3/dist-packages/ansible_compat/runtime.py:242: AnsibleWarning
_________________________________________________________________________________________ test_template[to_json_filter_on_undefined_variable] _________________________________________________________________________________________
template = '{{ hello | to_json }}', output = '{{ hello | to_json }}'
@pytest.mark.parametrize(
("template", "output"),
(
pytest.param("{{ playbook_dir }}", "/a/b/c", id="simple"),
# Does not work the same with ansible 2.19 with data tagging
# pytest.param(
# "{{ 'hello' | doesnotexist }}",
# "hello", # newer implementation ignores unknown filters
# id="unknown_filter",
# ),
pytest.param(
"{{ hello | to_json }}",
"{{ hello | to_json }}",
id="to_json_filter_on_undefined_variable",
),
pytest.param(
"{{ hello | to_nice_yaml }}",
"{{ hello | to_nice_yaml }}",
id="to_nice_yaml_filter_on_undefined_variable",
),
),
)
def test_template(template: str, output: str) -> None:
"""Verify that resolvable template vars and filters get rendered."""
> result = utils.template(
basedir=Path("/base/dir"),
value=template,
variables={"playbook_dir": "/a/b/c"},
fail_on_error=False,
)
test/test_utils.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/ansiblelint/utils.py:315: in template
value = ansible_template(
/usr/lib/python3/dist-packages/ansiblelint/utils.py:209: in ansible_template
templated = templar.template(varname, **kwargs) # type: ignore[no-untyped-call]
/usr/lib/python3/dist-packages/ansible/template/__init__.py:280: in template
_display.deprecated(
/usr/lib/python3/dist-packages/ansible/utils/display.py:678: in deprecated
self._deprecated_with_plugin_info(
/usr/lib/python3/dist-packages/ansible/utils/display.py:735: in _deprecated_with_plugin_info
self._deprecated(deprecation)
/usr/lib/python3/dist-packages/ansible/utils/display.py:388: in wrapper
return func(self, *args, **kwargs)
/usr/lib/python3/dist-packages/ansible/utils/display.py:747: in _deprecated
self.warning('Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ansible.utils.display.Display object at 0x7fc86d1657f0>, msg = 'Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.', formatted = False
def warning( # noqa: DOC103
self: Display, # noqa: ARG001
msg: str,
formatted: bool = False, # noqa: ARG001,FBT001,FBT002
*,
help_text: str | None = None, # noqa: ARG001
obj: Any = None, # noqa: ARG001,ANN401
) -> None: # pragma: no cover
"""Override ansible.utils.display.Display.warning to avoid printing warnings."""
> warnings.warn(
message=msg,
category=AnsibleWarning,
stacklevel=2,
source={"msg": msg},
)
E ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
/usr/lib/python3/dist-packages/ansible_compat/runtime.py:242: AnsibleWarning
______________________________________________________________________________________ test_template[to_nice_yaml_filter_on_undefined_variable] _______________________________________________________________________________________
template = '{{ hello | to_nice_yaml }}', output = '{{ hello | to_nice_yaml }}'
@pytest.mark.parametrize(
("template", "output"),
(
pytest.param("{{ playbook_dir }}", "/a/b/c", id="simple"),
# Does not work the same with ansible 2.19 with data tagging
# pytest.param(
# "{{ 'hello' | doesnotexist }}",
# "hello", # newer implementation ignores unknown filters
# id="unknown_filter",
# ),
pytest.param(
"{{ hello | to_json }}",
"{{ hello | to_json }}",
id="to_json_filter_on_undefined_variable",
),
pytest.param(
"{{ hello | to_nice_yaml }}",
"{{ hello | to_nice_yaml }}",
id="to_nice_yaml_filter_on_undefined_variable",
),
),
)
def test_template(template: str, output: str) -> None:
"""Verify that resolvable template vars and filters get rendered."""
> result = utils.template(
basedir=Path("/base/dir"),
value=template,
variables={"playbook_dir": "/a/b/c"},
fail_on_error=False,
)
test/test_utils.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/ansiblelint/utils.py:315: in template
value = ansible_template(
/usr/lib/python3/dist-packages/ansiblelint/utils.py:209: in ansible_template
templated = templar.template(varname, **kwargs) # type: ignore[no-untyped-call]
/usr/lib/python3/dist-packages/ansible/template/__init__.py:280: in template
_display.deprecated(
/usr/lib/python3/dist-packages/ansible/utils/display.py:678: in deprecated
self._deprecated_with_plugin_info(
/usr/lib/python3/dist-packages/ansible/utils/display.py:735: in _deprecated_with_plugin_info
self._deprecated(deprecation)
/usr/lib/python3/dist-packages/ansible/utils/display.py:388: in wrapper
return func(self, *args, **kwargs)
/usr/lib/python3/dist-packages/ansible/utils/display.py:747: in _deprecated
self.warning('Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ansible.utils.display.Display object at 0x7fc86d1657f0>, msg = 'Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.', formatted = False
def warning( # noqa: DOC103
self: Display, # noqa: ARG001
msg: str,
formatted: bool = False, # noqa: ARG001,FBT001,FBT002
*,
help_text: str | None = None, # noqa: ARG001
obj: Any = None, # noqa: ARG001,ANN401
) -> None: # pragma: no cover
"""Override ansible.utils.display.Display.warning to avoid printing warnings."""
> warnings.warn(
message=msg,
category=AnsibleWarning,
stacklevel=2,
source={"msg": msg},
)
E ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
/usr/lib/python3/dist-packages/ansible_compat/runtime.py:242: AnsibleWarning
_________________________________________________________________________________________________________ test_find_children __________________________________________________________________________________________________________
default_rules_collection = <ansiblelint.rules.RulesCollection object at 0x7fc869714750>
def test_find_children(default_rules_collection: RulesCollection) -> None:
"""Verify correct function of find_children()."""
Runner(
rules=default_rules_collection,
> ).find_children(Lintable("examples/playbooks/find_children.yml"))
test/test_utils.py:430:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/ansiblelint/runner.py:533: in find_children
for child in self.play_children(
/usr/lib/python3/dist-packages/ansiblelint/runner.py:594: in play_children
v = template(
/usr/lib/python3/dist-packages/ansiblelint/utils.py:315: in template
value = ansible_template(
/usr/lib/python3/dist-packages/ansiblelint/utils.py:209: in ansible_template
templated = templar.template(varname, **kwargs) # type: ignore[no-untyped-call]
/usr/lib/python3/dist-packages/ansible/template/__init__.py:280: in template
_display.deprecated(
/usr/lib/python3/dist-packages/ansible/utils/display.py:678: in deprecated
self._deprecated_with_plugin_info(
/usr/lib/python3/dist-packages/ansible/utils/display.py:735: in _deprecated_with_plugin_info
self._deprecated(deprecation)
/usr/lib/python3/dist-packages/ansible/utils/display.py:388: in wrapper
return func(self, *args, **kwargs)
/usr/lib/python3/dist-packages/ansible/utils/display.py:747: in _deprecated
self.warning('Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ansible.utils.display.Display object at 0x7fc86d1657f0>, msg = 'Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.', formatted = False
def warning( # noqa: DOC103
self: Display, # noqa: ARG001
msg: str,
formatted: bool = False, # noqa: ARG001,FBT001,FBT002
*,
help_text: str | None = None, # noqa: ARG001
obj: Any = None, # noqa: ARG001,ANN401
) -> None: # pragma: no cover
"""Override ansible.utils.display.Display.warning to avoid printing warnings."""
> warnings.warn(
message=msg,
category=AnsibleWarning,
stacklevel=2,
source={"msg": msg},
)
E ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
/usr/lib/python3/dist-packages/ansible_compat/runtime.py:242: AnsibleWarning
======================================================================================================== slowest 10 durations =========================================================================================================
7.37s call test/test_app.py::test_with_inventory_concurrent_syntax_checks
5.76s call test/test_runner.py::test_runner[lots_of_warnings]
3.73s call test/test_formatter_json.py::test_code_climate_parsable_ignored
3.60s call test/test_formatter_sarif.py::test_sarif_parsable_ignored
3.21s call test/test_utils.py::test_import_playbook_children_subdirs
3.20s call test/test_utils.py::test_import_playbook_children
2.85s call test/test_cli_role_paths.py::test_run_multiple_role_path_no_trailing_slash
2.72s call test/test_cli_role_paths.py::test_run_single_role_path_with_roles_path_env
2.71s call test/test_cli_role_paths.py::test_run_multiple_role_path_with_trailing_slash
2.71s call test/test_utils.py::test_include_children_load_playbook_failed_syntax_check
======================================================================================================= short test summary info =======================================================================================================
FAILED test/test_utils.py::test_template[simple] - ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
FAILED test/test_utils.py::test_template[to_json_filter_on_undefined_variable] - ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
FAILED test/test_utils.py::test_template[to_nice_yaml_filter_on_undefined_variable] - ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
FAILED test/test_utils.py::test_find_children - ansible_compat.runtime.AnsibleWarning: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
================================================================================ 4 failed, 565 passed, 3 skipped, 108 deselected in 140.36s (0:02:20) =================================================================================
[...]
Desired Behavior
Tests should pass
Actual Behavior
Tests fail like above.
Metadata
Metadata
Assignees
Type
Projects
Status
No status