Deprecation warning when using variable that is a list

24 views
Skip to first unread message

Eric Secrist

unread,
Jul 20, 2016, 10:53:18 AM7/20/16
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages