list - ansible:引用同一列表中的变量
问题描述
我有一个这样的列表(示例的缩写)
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' 未定义"}
解决方案
这是不可能的。请参阅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 }}"
推荐阅读
- function - 关于godot 3.2中是否存在特定功能的问题
- r - R时间序列从一天到一个月
- android - CERTIFICATE_VERIFY_FAILED:所有 Flutter 应用的证书已过期
- python - Django 与 Djongo,EmbeddedFields 返回模型尚未加载
- java - 以静态方法复制数组Java时的奇怪行为
- javascript - jQuery停止函数在已被其他事件调用时被调用
- python - 如何在这个 Python 脚本中处理 CSV 文件
- linux - Raspbian Eclipse JDK11 内存
- haskell - cabal install gving errror as LICENSE: openBinaryFile: 不存在(没有这样的文件或目录)
- java - 如何在 kubernetes-client-java 中创建 Ingress Controller