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

Misleading deprecation message #12282

Closed
jmeickle opened this issue Sep 8, 2015 · 8 comments
Closed

Misleading deprecation message #12282

jmeickle opened this issue Sep 8, 2015 · 8 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@jmeickle
Copy link
Contributor

jmeickle commented Sep 8, 2015

On running a playbook with ansible 2.0.0 (devel 2d251cba45) last updated 2015/09/04 15:50:24 (GMT -400), I got this error message:

[DEPRECATION WARNING]: Specifying include variables at the top-level of the task
 is deprecated. Please see:
http://docs.ansible.com/ansible/playbooks_roles.html
#task-include-files-and-encouraging-reuse

for currently supported syntax 
regarding included files and variables. This feature will be removed in a future
 release. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.

This was very hard to track down, and should have a line number or task name or something. After a while I was able to pin it down to this section of a role, where I was running several files in an include as root:

- include: setup-RedHat.yml
  # become: yes
  sudo: yes
  when: ansible_os_family == 'RedHat'

- include: setup-Debian.yml
  # become: yes
  sudo: yes
  when: ansible_os_family == 'Debian'

Switching from 'sudo' to 'become' fixes this problem. So I think what's happening here is that because sudo is deprecated, it's not on the acceptable attribute list; that leads to sudo being seen as a variable being passed to the task in a deprecated way, rather than as an attribute of the task.

I'd recommend both improving the error message, and including deprecated attributes in a second check performed before the variable-passing deprecation check.

@bcoca bcoca added this to the v2 milestone Sep 8, 2015
@jimi-c jimi-c closed this as completed in ee7905c Sep 10, 2015
@jimi-c
Copy link
Member

jimi-c commented Sep 10, 2015

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@arpit-goel
Copy link

Hi @jimi-c ,
The bug doesn't seem to be completely resolved. I'm running ansible-playbook 2.1.0.0.
I receive the same error message one Eronarn received. However, he was able to resolve the issue changing sudo to become but I wasn't as I had already done that change before receiving this error. As far as I understand from the message, there shouldn't be variables defined with the include statement. Going to the link doesn't prove to be much help as the message in the error and content on page doesn't match.
Here are my task file:

- include: env.yml
  tag: provision,env

And here's my env.yml:

- name: Configure environment variables
  template: src=env/.{{ env_name }}.j2 dest="{{ deploy_directory }}/.env" force=yes
  register: environment_vars_check

- name: restart supervisor
  become: yes
  become_user: root
  become_method: sudo
  command: restart supervisor
  when: environment_vars_check.changed

- name: Add env to deployer user bashrc
  blockinfile:
    dest: "/home/{{ deploy_user }}/.bashrc"
    backup: "yes"
    state: "present"
    insertafter: "EOF"
    marker: "# {{ version }} {mark}"
    content: |
        while read line
        do
                export $line
        done < {{ deploy_directory }}/.env
  when: inventory_hostname in groups.appservers

Please look into the issue.

@jimi-c
Copy link
Member

jimi-c commented Jun 7, 2016

@arpit-goel could you please open a new issue for this?

@anderskandersson
Copy link

I got the same message when I mistakenly wrote tools instead of tags

- include: foo.yml
  tools: mytag

Tested with Ansible v2.0.2.0-1 and v2.1.1.0-0.1.rc1

@iturgeon
Copy link

iturgeon commented Feb 3, 2017

Thanks @anderskandersson, mistyped tag: instead of tags: and it was interpreted as a variable name resulting in this error.

@avpines
Copy link

avpines commented May 21, 2017

Still happening in 2.3.0.0, wrote run_one instead of run_once and got this message. Very confusing, no line number or anything.

@BusterNeece
Copy link

+1, this issue should most certainly be reopened. When I read the error message, it suggests that the very act of including tasks at the base of a YML file is deprecated, which is impossible as this basically the entire foundation of how Ansible works.

Instead, based on a look at the code, it appears it's trying to tell me that one particular attribute, somewhere amidst all of my Ansible files, is deprecated. It's not kind enough to tell me which one, or where it is, so this is a frustrating guessing game.

@JoelFeiner
Copy link

JoelFeiner commented Aug 25, 2017

It looks like a new issue was opened, as requested (#16183), but was then closed as a user error. I will file a new ticket and hopefully this one will get traction.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

10 participants