Bulk Add Users
[email protected] init]# cat Useradds.sls
{% Set users = [' name1,name2 ']%}
{% for user in users%}
{{User}}:
User.present:
-Shell:/bin/bash
-Home:/home/{{User}}
-Password: ' $1$sbvwg7.v$r/nwds7g0yynb1cvsfupa/'
-Groups:
-{{User}}
-Require:
-Group: {{User}}
Group.present:
-Name: {{User}}
{% ENDFOR%}
Password is the password after the hash
Get hash password for ciphertext after OpenSSL passwd-1
[email protected] init]# OpenSSL passwd-1
Password:
Verifying–password:
$1$bwsi2gyh$v.jqn/fe9j3yltwxco.cq/
Bulk Delete Users
[email protected] init]# cat Userdel.sls
{% Set users = [' Jerry ', ' Tom ', ' Sunday ']%}
{% for user in users%}
{{User}}:
User.absent:
-Purge:true
-Force:true
{% ENDFOR%}
-Purge:true # #Set purge to True to delete all of the user's files as well as the user, and Default is False.
-Force:true # #如果用户当前已登录, the absent state fails. When the force option is set to True, the user is deleted even if the user is currently logged on.
This article is from the "yangspring" blog, please be sure to keep this source http://ycccc.blog.51cto.com/6385403/1715923
Saltstack Bulk Add Bulk Delete users