[root@comk Desktop]# cat adduser.yaml
- name: add users
remote_user: root
hosts: webservers
tasks:
- name: add users
user: name={{ item }} state=present
with_items:
- testuser1
- testuser2
adduser.yaml 中将with_items: 下面的- 和with_items对齐就好了
另外加 chmod +x adduser.yaml 要加上执行权限
- name: add users
hosts: webservers
tasks:
- name: add users
user: name=`item` state=present
with_items:
- testuser1
- testuser2