标签: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
原文地址:http://ycccc.blog.51cto.com/6385403/1715923