Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'"include" is deprecated, use include_tasks/import_tasks instead.' deprecation warning is without link to place explaining how to deal with it #76684

Closed
1 task done
matkoniecz opened this issue Jan 8, 2022 · 8 comments · Fixed by #77599
Labels
affects_2.12 docs This issue/PR relates to or includes documentation. easyfix This issue is considered easy to fix by aspiring contributors. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@matkoniecz
Copy link

matkoniecz commented Jan 8, 2022

Summary

I noticed

[DEPRECATION WARNING]: "include" is deprecated, use include_tasks/import_tasks instead. This feature will be removed in version 2.16.

Sadly, this deprecation warning is without link to documentation explaining how it should be fixed

I went to changelog: but https://github.com/ansible/ansible/blob/devel/changelogs/CHANGELOG.rst is not really helping with finding documentation

searching import_tasks include_tasks difference ansible on internet found finally https://serverfault.com/questions/875247/whats-the-difference-between-include-tasks-and-import-tasks

Every single person using Ansible will need to search for about 2 to 10 minutes - multiply it by number of Ansible users and there is quite big waste of time.

If there is a good reason to deprecate something - please link to documentation explaining how to fix code that worked fine so far.

Or maybe at least mention which version is equivalent to the current behaviour.

(ideally there would be ansible undeprecate_include which would edit all instances of include to whichever version is matching current one and ansible undeprecate_include include_tasks which would use include_tasks and ansible undeprecate_include import_tasks)

Issue Type

Documentation Report

Component Name

ansible (sorry)

Ansible Version

$ ansible --version

ansible [core 2.12.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/mateusz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/mateusz/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True

Configuration

$ ansible-config dump --only-changed

(no visible output)

OS / Environment

Lubuntu 20.04

Additional Information

No googling needed to find docs, lower risk of finding misleading docs

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@matkoniecz
Copy link
Author

matkoniecz commented Jan 8, 2022

My reading is that replacing all by import_tasks is safe if I am not doing anything weird like dynamically generating/editing task files or conditionals ( https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#applying-when-to-roles-imports-and-includes ).

@ansibot ansibot added affects_2.12 docs This issue/PR relates to or includes documentation. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 8, 2022
matkoniecz added a commit to matkoniecz/recovery-with-ansible that referenced this issue Jan 8, 2022
@bcoca bcoca added easyfix This issue is considered easy to fix by aspiring contributors. and removed needs_triage Needs a first human triage before being processed. labels Jan 11, 2022
@bcoca
Copy link
Member

bcoca commented Jan 11, 2022

@sivel
Copy link
Member

sivel commented Jan 11, 2022

@philipfreude
Copy link

It would also be useful to be able to see the files and line numbers where a deprecated "include" is still used.

@sivel
Copy link
Member

sivel commented Jan 28, 2022

grep -HRn ' include:' *

@bcoca
Copy link
Member

bcoca commented Jan 28, 2022

we try to keep the warnings generic so we can dedupe, otherwise the user would be flooded with warning messages if they have multiple includes in the play. Also easy to find them as @sivel has already pointed out (git grep also works!)

jonathanmorgan added a commit to jonathanmorgan/ansible-patterns-centos that referenced this issue Feb 10, 2022
jonathanmorgan added a commit to jonathanmorgan/ansible-patterns that referenced this issue Feb 10, 2022
@ansibot ansibot added the has_pr This issue has an associated PR. label Feb 13, 2022
@samccann
Copy link
Contributor

Notes on how to include a link in an error message like this:

Here's an example: https://github.com/ansible/ansible/blob/devel/lib/ansible/executor/interpreter_discovery.py#L130 - I n place of including a static URL when an error message is being built, use get_versioned_doclink (from ansible.utils.plugin_docs) with a relative link to the as-rendered filename from the versioned root of the docsite. eg: get_versioned_doclink('reference_appendices/interpreter_discovery.html') in 2.12 comes out in the error message as https://docs.ansible.com/ansible-core/2.12/reference_appendices/interpreter_discovery.html

@samccann
Copy link
Contributor

samccann commented Apr 21, 2022

Actual file where this error message exists is - https://github.com/ansible/ansible/blob/devel/lib/ansible/playbook/helpers.py#L158

and the relative doclink is user_guide/playbooks_reuse_includes.html

will need to add from ansible.utils.plugin_docs import get_versioned_doclink to top of file as well.

@ansible ansible locked and limited conversation to collaborators May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.12 docs This issue/PR relates to or includes documentation. easyfix This issue is considered easy to fix by aspiring contributors. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants