Ansible:[不推荐使用警告]:不推荐使用裸变量
我认为这是剧本中产生错误的部分。我应该如何重新编写这部分Ansible:[不推荐使用警告]:不推荐使用裸变量,ansible,Ansible,我认为这是剧本中产生错误的部分。我应该如何重新编写这部分 roles: - role: json-transform json_transforms: '{{ clientValidation.json_transforms}}' 它抛出以下警告: [DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the f
roles:
- role: json-transform
json_transforms: '{{ clientValidation.json_transforms}}'
它抛出以下警告:
[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{json_transforms}}'). This feature will be removed in a
future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
看起来你的最高级别没有什么问题——这可能是你的角色内部的问题。不推荐使用的裸变量通常出现在带有xxx循环的
上;例如:
- hosts: blar
vars:
items:
- one
- two
tasks:
- debug: msg="hi from {{ item }}"
with_items: items
在本例中,它告诉您with_items:items
应该是with_items:“{{items}}”
您使用的是什么Ansible版本?这种语法在我看来有点奇怪,通常我会使用这样的语法:-{role:json transform,json_transforms:{{{clientValidation.json_transforms}}}
所以您可能想试试。我使用的是Ansible 2.0.1,我已经尝试了您提到的内容,但它不起作用。语法没关系-@ydaetskcoR只是使用内联dict语法,而不是扩展的yaml dict语法。它们在解析的文档中是完全相同的。似乎这个问题与这里的主题有某种关联[1]。通常发生在您尝试对裸变量使用then“when”方法进行验证时。在ansible 2.8及以上版本中,您应该使用类似于when:myVariable | bool
的内容,以符合最新标准[1]