rakesh_singh
rakesh_singh

Reputation: 86

Using include_vars in Ansible task

I have an Ansible role and I've used include_vars in my main.yml task. The task is working, but I have noticed the following warning when running in verbose mode.

[DEPRECATION WARNING]: Specifying include variables at the top-level of 
the task is
deprecated. Please see: 
https://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 version 2.12. 
Deprecation
warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.

file: role_name/tasks/main.yml

 - name: Reference variable files
   include_vars: "{{ item }}"
   with_first_found:
     - "{{ ansible_distribution|lower }}.yml"
     - "{{ ansible_virtualization_type }}.yml"
     - default.yml

The URL provided in the warning message does not provide a clear solution.

Where is the correct place to reference these variable files?

Thanks

ansible 2.7.2 python version = 2.7.15 (v2.7.15:ca079a3ea3, Apr 29 2018, 20:59:26) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

Reference: https://docs.ansible.com/ansible/2.7/modules/include_vars_module.html

Upvotes: 0

Views: 901

Answers (1)

rakesh_singh
rakesh_singh

Reputation: 86

Based on the following article: https://github.com/ansible/ansible/issues/12282

I tried comment out the entire task and the warning message continued to be displayed.

I then remove the tag tag: check_vg in the tasks that followed:

- name: Reference variable files
   include_vars: "{{ item }}"
   with_first_found:
     - "{{ ansible_distribution|lower }}.yml"
     - "{{ ansible_virtualization_type }}.yml"
     - default.yml

 - name: Run App Volume Group Configuration Task
   include: app_vg_config.yml
   when: configure_app_vg == true
   tag: check_vg  # <- This seems to cause an issue

The task now runs without any warning.

Upvotes: 1

Related Questions