Ansible:[弃用警告]:不推荐使用裸变量
问题描述:
我认为这是产生错误的剧本部分.我应该如何重写这部分?
I think this is the part of the playbook that is generating the error. How should I be re-writing this part?
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.
答
看起来您的最高级别没有任何问题 - 这可能是您角色内部的问题.不推荐使用的裸变量通常出现在 with_xxx
循环中;例如:
It doesn't look like there's anything wrong with your top level- it's probably something inside your role. Deprecated bare variables usually occur on a with_xxx
loop; eg:
- hosts: blar
vars:
items:
- one
- two
tasks:
- debug: msg="hi from {{ item }}"
with_items: items
在这种情况下,它告诉您 with_items: items
应该是 with_items: "{{ items }}"
.
In this case, it's telling you that with_items: items
should be with_items: "{{ items }}"
.