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

    

猜你喜欢

转载自www.cnblogs.com/pzk7788/p/10215927.html