ansible 批量修改root密码
[root@sz_fy_virt_encrypt_33_239 fetch]# cat /opt/passwd.yml
- hosts: web
vars:
path: /home/opsadmin
remote_user: opsadmin
become: yes
become_method: sudo
become_user: root
tasks:
- name: Generate random number
shell: openssl rand -base64 | cut -b - > /tmp/.openssl - name: modify passwd
shell: echo `cat /tmp/.openssl`|passwd --stdin root - name: fetch remote file
fetch:
src: /tmp/.openssl
dest: "{{ path }}/fetch/passwd-{{ inventory_hostname }}"
flat: yes - name: delete passwd file
shell: rm -f /tmp/.openssl - name: create pssswd file
shell: for i in `ls ~/fetch`;do echo -e ${i##passwd-},`cat ~/fetch/$i` >> ~/fetch/.`date +%F`-passwd;done vim /etc/ansible/hosts
10.8.20.200 ansible_user=xxx ansible_sudo_pass="xxx" ansible_ssh_port=123455 ssh-copy-id -i /home/opsadmin/.ssh/id_rsa.pub '-p 37600 opsadmin@172.20.51.73'
执行效果

ansible 批量修改root密码的更多相关文章
- Ansible批量修改root密码
0x01:首先做好免密登录 http://www.cnblogs.com/evlon/p/8094306.html 0x02:批量修改密码 ansible all -m raw -a "ec ...
- ansible非root用户批量修改root密码
前言: 由于线上服务器密码长久没有更新,现领导要求批量更换密码.线上的之前部署过salt,但由于各种因素没有正常使用. 使用自动化工具批量修改的计划搁浅了,后来领导给了个python多线程修改密码脚本 ...
- 批量修改root密码
公司有五十多台服务器.每台服务器中使用的密码完全不同,同时操作系统也不一样,centos5,6,7 .ubuntu,windows都有,更不用提其中各种小版本. root密码定期更改是一个大问题(wi ...
- ansible批量修改用户密码
实现批量修改目标主机多个用户密码: --- - hosts: testchanange passwd gather_facts: false tasks: - name: change you pas ...
- ansible批量修改服务器密码
看了一下网上代码大多数是ansible-playbook实现的,需要写一个脚本,或者手动传递变量进去. 以前用python tcp模块写过客户端主动上报修改密码脚本 今天写一个ansible主控客户端 ...
- linux系统批量修改root密码
#!/bin/bash ip_list=(192.168.36.12 192.168.36.13) remote_cmd="echo new-passwd | passwd --stdin ...
- linux批量修改root密码脚本
转至:https://blog.csdn.net/onionm/article/details/100514892?utm_medium=distribute.pc_relevant_download ...
- Python 批量修改root密码
#_*_coding:utf8_*_ from multiprocessing import Process, Pool import paramiko import sys,os host_list ...
- Ansible playbook 批量修改服务器密码 先普通后root用户
fsckzy Ansible playbook 批量修改服务器密码 客户的需求:修改所有服务器密码,密码规则为Rfv5%+主机名后3位 背景:服务器有CentOS6.7,SuSE9.10.11,r ...
随机推荐
- spring boot打包问题
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories ...
- python2.7入门---file(文件)&OS 文件&目录方法
首先file 对象使用 open 函数来创建,下表列出了 file 对象常用的函数: 序号 方法及描述 1 file.close() 关闭文件.关闭后文件不能再进行读写操作. 2 file.f ...
- Ubuntu无法安装vim怎么办?(Ubuntu 出现apt-get: Package has no installation candidate问题)
apt-get install vim 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 有一些软件包无法被安装.如果您用的是不稳定(unstable)发行版, ...
- VM打开虚拟机文件报错
用VM打开以前的虚拟机文件报错 Cannot open the disk 'F:/****.vmdk' or one of the snapshot disks it depends on. 这种问题 ...
- 初识Continuation
本文来自网易云社区 作者:陆艺 上学时看了SICP之后就对scheme这个看上去比较古怪的语言产生了兴趣. 虽然书里并没有涉及scheme太多语法以及语言上特性的一些东西, 作为一个喜欢折腾的人, 手 ...
- 26、js阶段性复习
1.一元运算符 Operator + 可用于将变量转换为数字: <!DOCTYPE html> <html> <body> <p> typeof 操作符 ...
- ES5新增数组方法(4):every
检查数组元素的每个元素是否符合条件. // 数组中的元素全部满足指定条件返回true let arr = [1, 3, 5, 7, 9]; console.log(arr.every((value, ...
- ASP NET Core ---REST & HTTP GET
参照 草根专栏- ASP.NET Core + Ng6 实战:https://v.qq.com/x/page/h0764n405ll.html 一.REST (Representational Sta ...
- oracle 数据库字段名与实体类字段名称不匹配的处理方法
之前公司一直都使用sql server 即使数据库字段名称与实体类名称不相同 可以使用诸如: select id as userId from tb_user 这种写法,可换到了oracle 之后坑爹 ...
- CPU拓扑结构
本篇旨在认识一下以下三种CPU拓扑结构分别是什么: Symmetric multiprocessing (SMP) Non-uniform memory access (NUMA) Simultane ...