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

问题描述 投票:0回答:1

在服务器1上我有ansible 2.4.2.0与python版本= 2.7.5:

在服务器2上我有ansible 2.6.0与python版本= 3.6.3:

在Server 1上,通过在roles / webapp / vars / main.yml中调用字典roles / webapp / defaults / 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版本之间是否有任何修改,我在版本2.5和2.6的ansible changelog上都没有找到任何内容?

python ansible ansible-2.x
1个回答
1
投票

我尝试了两件事,它有效:

  1. 直接在/role/test/vars/main.yml中添加字典
  2. 添加到ansible配置文件(ansible.cfg) hash_behaviour =合并
© www.soinside.com 2019 - 2024. All rights reserved.