繁体   English   中英

在Ansible任务中使用include_vars

[英]Using include_vars in Ansible task

我有一个Ansible角色,并且在main.yml任务中使用了include_vars 该任务正在运行,但是在详细模式下运行时,我注意到以下警告。

[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.

文件: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

警告消息中提供的URL不能提供明确的解决方案。

引用这些变量文件的正确位置在哪里?

谢谢

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)]

参考: https : //docs.ansible.com/ansible/2.7/modules/include_vars_module.html

基于以下文章: https : //github.com/ansible/ansible/issues/12282

我尝试注释掉整个任务,并继续显示警告消息。

然后,在随后的任务中删除标记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

现在,该任务运行,没有任何警告。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM