- hosts: 22rrvgndns01
gather_facts: no
vars_files:
- /etc/ansible/dnschange/dns_resource_record.yml
tasks:
- shell: grep "{{item.name}}" check_result.txt
args:
chdir: /cluster/dnschange
when: "{{item.action}}" is match("delete")
with_items: "{{resource_record}}"
这是resource_record:
- resource_record:
- name: test.201.apn.epc.mnc002.mcc505.3gppnetwork.org
record_type: naptr
action: create
view: MME
ttl: 300
order: 100
preference: 999
flags: s
service: x-3gpp-pgw:x-gn:x-gp:x-s5-gtp
replacement: wip-ows-pgw-e-NSW.node.epc.mnc002.mcc505.3gppnetwork.org
执行脚本时出现错误
违规行似乎是:
chdir: /cluster/dnschange
when: "{{item.action}}" is match("delete")
^ here
我可能是错的,但这似乎是一个问题 缺少引号。总是在引用模板表达式括号时 开始一个值。例如:
with_items:
- {{ foo }}
应写为:
with_items:
- "{{ foo }}"
有人可以帮我吗?