Ansible Playbook 使用循环语句

如下,with_items 是循环的对象,with_items 是 python list 数据结构,task 会循环读取 list 里面的值,key 的名称是 item

[root@localhost ~]$ cat while.yml              
---
- hosts: 192.168.119.134
  user: root
  tasks:
    - name: touch file
      file: path=/tmp/{{ item }} state=touch mode=600
      with_items:
        - 1.txt
        - 2.txt
        - 3.txt

 

 

 

 

 

    

posted @ 2019-01-03 17:49  孔雀东南飞  阅读(425)  评论(0编辑  收藏  举报