Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible:[不推荐使用警告]:不推荐使用裸变量_Ansible - Fatal编程技术网

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]