ansible 2.4 (python 2.7.5) 和 ansible 2.6 (python 3.6.3) 字典语法区别?

ansible 2.4 (python 2.7.5) and ansible 2.6 (python 3.6.3) dictionary syntax difference?

在服务器 1 上我有 ansible 2.4.2.0 python version = 2.7.5 :

在服务器 2 上我有 ansible 2.6.0 python version = 3.6.3 :

在服务器 1 上,通过在 中调用字典 roles/webapp/defaults/main.yml 可以正常工作roles/webapp/vars/main.yml:

nexus_download_url: '{{ nexus_redirect_base_url }}?r={{ nexus_repo_name }}&g={{ apps[application_name].artifact_group_id }}&a={{ application_name }}&v={{ application_version }}&c=exec&e=jar'

在服务器 2 上出现以下错误:

{"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute...}

问题链接到:

&g={{ apps[application_name].artifact_group_id }}

两个 ansible 版本之间是否对字典语法进行了任何修改,我在 ansible 更新日志中没有找到 2.5 和 2.6 版本的任何内容?

我试过两件事,都奏效了:

  1. 直接在里面添加字典/role/test/vars/main.yml
  2. 添加到ansible配置文件(ansible.cfg)

    hash_behaviour = 合并