# Deprecation warning when using variable that is a list

**URL:** <https://forum.ansible.com/t/deprecation-warning-when-using-variable-that-is-a-list/22050>\
**Category:** Ansible Project\
**Created:** [July 19, 2016, 5:15pm UTC](https://forum.ansible.com/t/deprecation-warning-when-using-variable-that-is-a-list/22050 "2016-07-19T17:15:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Secrist](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@Eric\_Secrist](https://forum.ansible.com/u/Eric_Secrist)\
**Post date:** [July 19, 2016, 5:15pm UTC](https://forum.ansible.com/t/deprecation-warning-when-using-variable-that-is-a-list/22050/1 "2016-07-19T17:15:59Z")

</div>

Hello,  
This is my first post in this group. Please bear with my newbieness.

I am trying to clean up a deprecation warning in my ansible code, related to a variable I am using called ‘netgroups’, which is a list.

The code:

- name: Configure netgroups in sudoers.d  
template: src=sudoers.j2 dest=“/etc/sudoers.d/50\_{{ item }}” owner=root group=root mode=0400  
with\_flattened:
- [‘netgroups’]  
when: hostvars[inventory\_hostname][‘netgroups’][0] is defined

The warning:

TASK [common : Configure netgroups in sudoers.d] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the  
full variable syntax (‘{{netgroups}}’).  
This feature will be removed in a future release. Deprecation warnings can be  
disabled by setting deprecation\_warnings=False in ansible.cfg.  
changed: [localhost] =\> (item=netgroupZ)

Here is the ansible-playbook command:

export ANSIBLE\_HOST\_KEY\_CHECKING=False;ansible-playbook -i “localhost,” site.yml --connection=local --extra-vars “netgroups=[‘netgroupZ’]”

Note that the netgroups variable is set with the extra-vars option to a list in the ansible-playbook command. After changing [‘netgroups’] to ‘{{netgroups}}’ in the code, this error is received:

[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future this will be a fatal error.: ‘netgroups’ is  
undefined.  
This feature will be removed in a future release. Deprecation warnings can be disabled by setting  
deprecation\_warnings=False in ansible.cfg.  
skipping: [localhost]

Any ideas? Thanks in advance.
