码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack批量添加批量删除用户

时间:2015-11-23 14:54:30      阅读:631      评论:0      收藏:0      [点我收藏+]

标签:saltstack

批量添加用户

[root@linux-node1 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为hash后的密码
获取hash后密文密码openssl passwd -1
[root@linux-node1 init]# openssl passwd -1
Password:
Verifying – Password:
$1$bWsI2gYH$V.JqN/FE9J3yltwXCo.CQ/


批量删除用户

[root@linux-node1 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, Default is False.
- force: True  ##如果用户当前已登录,则absent state会失败. 设置force选项为True时,就算用户当前处于登录状态也会删除本用户.

本文出自 “杨春朝” 博客,请务必保留此出处http://ycccc.blog.51cto.com/6385403/1715923

saltstack批量添加批量删除用户

标签:saltstack

原文地址:http://ycccc.blog.51cto.com/6385403/1715923

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!