创建多个文件file1 file2 file3及安装多个包packge1 packge2 packge3
---
- hosts: a
remote_user: root
tasks:
- name: create files
file: name=/data/{{ item }} state=touch
with_items:
- file1
- file2
- file3
- name: install some packages
yum: name={{ item }}
with_items:
- packge1
- packge2
- packge3
- name: add users
user: name={{ item.user }} group={{ item.group }}
with_items:
- { name:'user1',group:'group1' }
- { name:'user2',group:'group2' }
- { name:'user3',group:'group3' }