saltstack批量添加批量删除用户

批量添加用户

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

批量删除用户

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

时间: 2024-08-23 12:33:55

saltstack批量添加批量删除用户的相关文章

批量添加或删除用户

========================================================================================== #!/bin/bash # if [ ! $# -eq 1 ];then echo './user.sh --add|--del' exit 1 fi case "$1" in --add) for i in {1..10} do if id user$i &>/dev/null ;then

123批量添加和删除单元格(扩展知识:设置单元格的尺寸和颜色)

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UITableViewController 4 @property (strong, nonatomic) NSMutableArray *mArrDataSource; 5 6 @end ViewController.m 1 #import "ViewController.h" 2 3 @interface Vi

Windows批量添加和删除IP

随着天气变冷了,好多小伙伴都开始变懒了,都想用最快的方式完成任务 下面给大家介绍一下Windows批量添加和删除IP的办法 (1)批量添加IP 直接在CMD下边运行下边命令. for /l %i in (2,1,254) do netsh interface ip add address "本地连接" 192.168.1.%i 255.255.255.0for /l %i in (2,1,62) do netsh interface ip add address "本地连接&

rhel7 批量新建和删除用户

若需要批量新建或者删除用户,可使用简单脚本操作. 首先新建 users.txt,将要新建或者删除的用户放进去, 1 andy 2 barry 3 carl 4 duke 5 eric 6 george 7 kim 8 mary 然后编写Example.sh,(新建用户) 1 then 2 echo "Already exists" 3 else 4 useradd $UNAME &> /dev/null 5 echo "$PASSWD" | passw

Ansible 从MySQL数据库添加或删除用户

mysql_user - 从MySQL数据库添加或删除用户. 概要 要求(在执行模块的主机上) 选项 例子 笔记 状态 支持 概要 从MySQL数据库添加或删除用户. 要求(在执行模块的主机上) MySQLdb的 选项 参数 需要 默认 选择 注释 append_privs (1.4 加入) no no yes no 将priv定义的权限附加到此用户的现有权限,而不是覆盖现有的权限. check_implicit_admin (1.3 加入) no no yes yes 检查mysql是否允许以

Linux系统编写shell脚本批量创建和删除用户

一.编写shell脚本批量添加用户 实现方法:判断用户是否存在,存在则返回错误提示,同时判断用户文件是否存在,不存在则退出 1.创建添加用户脚本 [[email protected] ~]# vim useradd.sh #!/bin/bashif [ $# -eq 0 ];then        echo "你没有输入任何文件!"        exit 1fi if [ ! -f $1 ];then        echo "输入有误!"        exit

linux批量添加10个用户并将其随机密码和用户名写入文件

需求: 批量新建10个测试用户,并且让其密码随机,把用户名和密码写入一个文件,并有创建时间和创建者 #!/usr/bin/python # -*- coding: utf-8 -*- import os import random import time import io def deluser(nums): '''删除用户测试用户''' for i in range(nums): username = 'stu' + str(i) linux_cmd = 'userdel -r {usern

SqlServer——批量操作(批量添加,删除)

批量添加数据: 一条insert语句批量插入多条记录 常见的insert语句,向数据库中,一条语句只能插入一条数据: insert into persons (id_p, lastname , firstName, city ) values(204,'haha' , 'deng' , 'shenzhen'); (如上,仅插入了一条记录) 怎样一次insert插入多条记录呢? 使用示例: insert into persons (id_p, lastname , firstName, city 

react.js 之 批量添加与删除功能

最近做的CMS需要用到批量添加图片的功能:在添加文件的容器盒子内,有两个内容,分别是:添加按钮与被添加的选择文件组件. 结构分析: 被添加的组件,我们称为:UploadQiNiuFiles(七牛文件上传组件),含一个删除当前组件的删除按钮 添加按钮的事件 被添加组件存放的容器 代码分析: 添加组件存放的容器:<div className="divBorder"> <div className="divBorder"> {addToBtn} /