with_items标准循环
ansible]# vim add.yml
---
- hosts: web2
remote_user: root
tasks:
- user:
name: "{{item.name}}"
group: "{{item.group}}"
password: "{{'123456'|password_hash('sha512')}}"
with_items:
- {name: "aa", group: "users"}
- {name: "bb", group: "mail" }
- {name: "cc", group: "wheel"}
- {name: "dd", group: "root" }
ansible]# ansible-playbook add.yml