ansible / ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you
https://ansible.readthedocs.io/projects/lint/
GNU General Public License v3.0
3.48k stars 657 forks source link

test_module_deprecated test fails on newer ansible #675

Closed webknjaz closed 3 years ago

webknjaz commented 4 years ago

Because of some changes in the Ansible Core repo, tests started failing 4 days ago. This needs to be investigated and fixed. PRs are welcome. If anybody wants to take this task, feel free to drop a comment here and then send a PR.

Issue Type

Ansible and Ansible Lint details

This is caused by a hardcoded list of deprecations from inside the linter at https://github.com/ansible/ansible-lint/blob/master/lib/ansiblelint/rules/DeprecatedModuleRule.py#L19-L29

This list does change with each version of ansible and some of these are now total failures.

We identified two potential new ways of interacting with ansible in a portable way:

ansible-doc -l -j |grep docker   
# ~3s to run, and returns only a list of modules, and deprecations still not visible
{                                                                                                                   "docker_compose": "Manage multi-container Docker applications with Docker Compose",
    "docker_config": "Manage docker configs",
    "docker_container": "manage docker containers",
}
ansible-doc --metadata-dump
# expensive (10s) to run and produces a dictionary of modules like
# biggest problem: it does not include deprecated modules or info about deprecation!!!
{
    "module_name": {
        "description": "...",
        "name": "...",
        "namespace": "...",
        "version_added": "..."
    }
}

Apparently ansible displays the deprecation warnings (module renames), only on STDERR when it encounteres an outdated name. Even worse is the fact that the stderr output is split on multiple lines due to https://github.com/ansible/ansible/issues/71461 and there is no option to collect these warnings. Apparently they were not implemented using python warnings support, and thus is not possible to collect them from outside.

The biggest challenge here is to find the list of deprecations and do it in a way that works for 2.8. 2.9 and 2.10

Desired Behaviour

List of deprecated modules should be dynamically retried from ansible itself and not being a static list.

Actual Behaviour (Bug report only)

One test started failing in the CI when running against ansible/ansible@devel. test/TestDeprecatedModule.py::TestDeprecatedModuleRule::test_module_deprecated: https://travis-ci.com/ansible/ansible-lint/jobs/285300600#L391

webknjaz commented 4 years ago

I've xfailed it. Whoever is going to implement the fix, must start by dropping the xfail mark from the test so that the actual test result will show up in the test results.

Ref: https://pganssle-talks.github.io/xfail-lightning.

greg-hellings commented 4 years ago

How feasible is it to do this, with most modules being pulled out of core and into the collections, now? Presumably these aren't easily located when you've only installed ansible-base on the system.