创建用户剧本user_add.yaml
- hosts: 192.168.45.135remote_user: roottasks:- name: linux system add user list.user: name={{ item }} state=presentwith_items:- xiaoxin1- xiaoxin2- xiaoxin3- xiaoxin4
删除用户剧本user_delete.yaml
- hosts: 192.168.45.135remote_user: roottasks:- name: linux system add user list.user: name={{ item }} state=absentwith_items:- xiaoxin1- xiaoxin2- xiaoxin3- xiaoxin4
执行脚本命令
ansible-playbook user_delete.yaml
执行结果
登录135服务器查看创建删除成功