ansible版本1.9.1
猫files.yml
tasks:
- name: stat files
stat: path=~/{{ item }}
register: {{ item }}.stat
with_items:
- foo.zip
- bar.zip
- name: copy files
copy: src=~/{{ item }} dest=/tmp/{{ item }}
register: {{ item }}.result
when: {{ item }}.stat.stat.exists == False
with_items:
- foo.zip
- bar.zip
- name: unzip files
shell: cd /tmp/ && unzip -o {{ item }}
when: {{ item }}.result|changed == True
with_items:
- foo.zip
- bar.zip
错误:语法错误而载入YAML脚本Ansible:如何使用登记在循环
如果是这样,怎么样?
哦,非常感谢! – yuezhonghua