[英]Using include_vars in Ansible task
I have an Ansible role and I've used include_vars
in my main.yml task. 我有一个Ansible角色,并且在main.yml任务中使用了include_vars
。 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 文件: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. 警告消息中提供的URL不能提供明确的解决方案。
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 参考: https : //docs.ansible.com/ansible/2.7/modules/include_vars_module.html
Based on the following article: https://github.com/ansible/ansible/issues/12282 基于以下文章: 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: 然后,在随后的任务中删除标记tag: check_vg
:
- 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. 现在,该任务运行,没有任何警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.