cha*_*bel 5 variables nested ansible
我的剧本中有一些变量如下:
---
first_var:
param1: value1
param2: value2
我想从命令行调用这些参数,如下所示:
ansible-playbook -i inventory site.yml -e 'first_var.param1=newvalue1'
但不起作用,我错过了什么吗?
仅当您将哈希行为修改为merge(这可能会破坏您的剧本)时,您才能执行此操作。
此外,为了使其工作,您需要将额外的变量作为 JSON 对象传递,这不适用于-e var=value.
命令行示例:
ANSIBLE_HASH_BEHAVIOUR=merge ansible-playbook -i inventory -e "{'first_var':{'param1':'newvalue1'}}" site.yml
Run Code Online (Sandbox Code Playgroud)