ansible:引用同一列表中的变量

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

我有一个这样的列表(示例的缩写)

vars:  
 cli:  
   terraform:  
     bin_name: "terraform"
     source_url: "https://releases.hashicorp.com.."  
     bin_to_copy: "/tmp/{{ bin_name }}"  

为什么以后无法访问{{bin_name}}名称?我尝试了cli.bin_name; item.bin_name; item.key.b ....错误始终是:失败! => {“ msg”:“'bin_name'未定义”}

list variables ansible
1个回答
0
投票

不可能。参见Can't reference a dict key inside the same dict #50280

FWIW。从字典中取出常用值。例如

vars:  
  my_bin_name: "terraform"
  cli:  
    terraform:  
      bin_name: "{{ my_bin_name }}"
      source_url: "https://releases.hashicorp.com.."  
      bin_to_copy: "/tmp/{{ my_bin_name }}"
© www.soinside.com 2019 - 2024. All rights reserved.