获取AnsibleError:模板化字符串时出现模板错误:应为标记'end of statement block',获取的是'{‘
这是我的jinja2模板,有人能帮我找出哪里出了问题吗?
no service pad
service tcp-keepalives-in
service tcp-keepalives-out
service timestamps debug datetime msec localtime show-timezone
service timestamps log datetime msec localtime show-timezone
service password-encryption
!
hostname {{item.hostname}}
!
boot-start-marker
boot-end-marker
!
logging buffered 32000
no logging console
!
!
{% for int in int_details_{{item.hostname}} %}
interface {{int.int}}
ip address {{int.ip}} {{int.mask}}
no shutdown
!
!
{% endfor %}
!
{% if (item.OSPF == 'Yes') and (item.hostname == 'R1') %}
router ospf {{item.OSPF_id}}
network 0.0.0.0 0.0.0.0 area {{item.OSPF_area}}
{% elif (item.OSPF == 'Yes') and (item.hostname == 'R2') %}
router ospf {{item.OSPF_id}}
network 0.0.0.0 0.0.0.0 area {{item.OSPF_area}}
{% elif (item.OSPF == 'Yes') and (item.hostname == 'R3') %}
router ospf {{item.OSPF_id}}
network 0.0.0.0 0.0.0.0 area {{item.OSPF_area}}
{% endif %}
end发布于 2019-03-31 17:36:08
这就是给您带来麻烦的代码行:{% for int in int_details_{{item.hostname}} %}。不能在jinja2指令中使用jinja2变量扩展。
这将解决您当前的问题:{% for int in lookup('vars', 'int_details_' + item.hostname) %}
https://stackoverflow.com/questions/55437561
复制相似问题