[root@Herry ansible]# cat create_doublefile.yml
---
- name: create_file to client
hosts: 192.168.224.131
user: root
#vars_files:
# - /etc/ansible/varfile.yml
gather_facts: false
tasks:
- name: create_directory
file: path=/tmp/{{ item.directory }} state=directory owner=root group=root mode=0755
- name: create_doublefile
file: path=/tmp/{{ item.directory }}/{{ item.file }} state=touch owner=root group=root mode=0755
with_items:
- { 'directory': [ "pythonstudy3", "pythonstudy3/999" ] }
- { 'file': [ 1.txt,2.txt,3.txt ] }
报错如下:
TASK [create_directory] ***********************************************************************************************************************************************
fatal: [192.168.224.131]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/etc/ansible/create_doublefile.yml': line 9, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: create_directory\n ^ here\n"}
to retry, use: --limit @/etc/ansible/create_doublefile.retry
为什么不行?
编辑回复