我有一个场景,我需要根据运行ansible playbook时传递的名为“provider”的字符串参数在groupvar中设置一个变量。在
ansible 2.3.0.0,python版本=2.7.5 分组_变量.yml,这就是我要达到的目标
if provider=azure then
insecure_registrys: ['{{azure_ip.state.ip_address}}:5000'] else if
provider=vsphere then
insecure_registrys: ['11.168.25.xx:5000']
在github中检查了一个问题后,我正在尝试这种方法
^{pr2}$上面的true将替换为provider check待会儿吧通过语法检查,但中途失败
FAILED! => {"failed": true, "msg": "{% if etcd_interface != '' %}{{ hostvars[inventory_hostname]['ansible_' + etcd_interface].ipv4.address }}{%- else %}{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}{% endif %}: template error while templating string: expected token ',', got '{'. String: {{ ( true | ternary('['{{azure_ip.state.ip_address}}:5000']','['11.168.25.xx:5000']'))}}"}
在这种情况下你能帮我吗?泰铢
不要使用嵌套的Jinja2表达式,更简单些:
三元过滤器:
^{pr2}$相关问题 更多 >
编程相关推荐