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

Capture and process Ansible DeprecationWarning exceptions #624

Open ssbarnea opened 4 years ago

ssbarnea commented 4 years ago

Issue Type

Desired Behaviour

Ansible can raise various DeprecationWarning exceptions while called by ansible-lint, and we should capture these and raise them as linting errors.

Rationale: the linting is the best place to raise these as errors because it does not run in production. In many cases users may even disable warnings in Ansible for deployments.

Obviously that when implemented as a rule, we should be able disable it just like the others.

Current Behaviour

Warnings can be seen on screen but the linter has no clue about them and the final result is still a success.

Examples:

[DEPRECATION WARNING]: os_server_facts is kept for backwards compatibility but
usage is discouraged. The module documentation details page may explain more
about this rationale.. This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.

[DEPRECATION WARNING]: os_subnets_facts is kept for backwards compatibility but
 usage is discouraged. The module documentation details page may explain more
about this rationale.. This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.

[DEPRECATION WARNING]: os_port_facts is kept for backwards compatibility but
usage is discouraged. The module documentation details page may explain more
about this rationale.. This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
webknjaz commented 4 years ago

Possible dupes: #246, #429.

prat98 commented 1 year ago

Are there any updates on this issue. Is it possible to add the deprecation warnings as linting errors? Or are these warnings still not collectible from Ansible-core as stated here https://github.com/ansible/ansible-lint/issues/246#issuecomment-690120328?

I also see in the ansible-lint docs there is a section for deprecated-module rules https://ansible.readthedocs.io/projects/lint/rules/deprecated-module/ but this issue describes ansible-lint not being able to detect deprecated modules. Should this be included in the documentation if it is currently not supported or is there a case where ansible-lint can detect deprecated modules?

ssbarnea commented 3 weeks ago

We already identify some of these, please mention if you spot others with latest version of linter and core.