ansible 开源批量管理服务器工具
Ansible 是一款基于 Python 开发的自动化运维工具,可以进行配置管理、批量部署等功能。对于机器较多的场景,可以使用 Ansible 来免去重复敲命令的烦恼。
- 安装ansible
yum -y install ansible
配置文件路径/etc/ansible/ansible.cfg
修改配置参数无需重启ansible
修改参数:host_key_checking = False (不修改可能出现无法连接服务器的情况)
提示:Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host. - 创建需要管理的服务器列表iplist
默认的iplist为:/etc/ansible/hosts
[group] 是组的别名,可以通过该组名对其下的所有机器进行控制
每一行内容分别是:机器别名、机器 IP、ssh 访问时使用的用户名、ssh 访问时使用的端口、ssh 访问时使用的密码
格式如下:
[web]
web_Server_0001 ansible_ssh_host=127.0.0.1 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass='passwd'
web_Server_0002 ansible_ssh_host=127.0.0.1 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass='passwd'
[db]
db_Server_0001 ansible_ssh_host=127.0.0.1 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass='passwd'
分别创建1组web服务器,1组db服务器,若密码有特殊字符,一定要使用单引号引起来,否则可能出现无法登陆服务器 - 日常脚本使用介绍
eg:显示列表下所有服务器的hostname
ansible all -i iplist -m shell -a "hostname"
all 代表所有组,也可指定组名
-i 指定iplist文件
-m 指定运行模块名称,如shell
-a 模块下可调用的命令
eg:给列表下服务器安装程序
ansible all -i iplist -m yum -a "name=vim"
命令可嵌套,可使用管道符
eg:
使用ansible分发文件
ansible all -i iplist -m copy -a "src=/home/file dest=/home/"
ansible 开源批量管理服务器工具的更多相关文章
- Ansible实现批量管理服务器
Ansible介绍: a. ansible是一个基于Python开发的自动化运维工具b. ansible是一个基于ssh协议实现远程管理的工具c. ansible软件可以实现多种批量管理操作(批量系统 ...
- Linux 运维工作中的经典应用ansible(批量管理)Docker容器技术(环境的快速搭建)
一 Ansible自动化运维工具 Python 在运维工作中的经典应用 ansible(批量管理操作) .安装ansible(需要bese epel 2种源) wget -O /etc/yum.rep ...
- Ansible playbook 批量修改服务器密码 先普通后root用户
fsckzy Ansible playbook 批量修改服务器密码 客户的需求:修改所有服务器密码,密码规则为Rfv5%+主机名后3位 背景:服务器有CentOS6.7,SuSE9.10.11,r ...
- 远程管理服务器--批量管理服务器,vps
一般大型的企事业单位都有自己的服务器,但是服务器一般都放在机房,辐射较大,噪音大,如何能有效的避免这一情况呢?哈哈,那就来个远程桌面,远程操作服务器吧. 一.使用 iis7远程连接管理工具工具下载官网 ...
- PSSH 批量管理服务器
pssh命令是一个python编写可以在多台服务器上执行命令的工具,同时支持拷贝文件,是同类工具中很出色的,类似pdsh,个人认为相对pdsh更为简便,使用必须在各个服务器上配置好密钥认证访问. 1. ...
- pssh批量管理服务器
pssh命令是一个python编写可以在多台服务器上执行命令的工具,同时支持拷贝文件,是同类工具中很出色的,类似pdsh,个人认为相对pdsh更为简便,使用必须在各个服务器上配置好密钥认证访问. 1. ...
- linux expect自动登陆远程服务器 批量管理服务器
#!/usr/bin/expect set ipaddress [lindex $argv 0] set passwd [lindex $argv 1] set timeout 3 spawn ssh ...
- CentOS7Linux中自动化运维工具Ansible的安装,以及通过模块批量管理多台主机
使用自动化运维工具Ansible集中化管理服务器 Ansible概述 Ansible是一款为类Unix系统开发的自由开源的配置和自动化工具.它用Python写成,类似于saltstack和Puppet ...
- ansible批量管理常见的配置方法
第7章 ansible的管理 7.1 ansible概念的介绍 ansible-playbook –syntax 检查语法 ansible-playbook -C ...
随机推荐
- linux中根据名称kill进程
shell函数如下: # kill processes by name kbn() { line=`ps -a | grep $1` arr=($line) for((i=0;i<${#arr[ ...
- shell脚本使用记录一:操作文件
一,连接远程数据库(保证在服务器上能使用mysql命令行,至少要安装mysql客户端) #!/bin/bash HOSTNAME="ip" PORT=" USERNAME ...
- PAT L3-016 二叉搜索树的结构
https://pintia.cn/problem-sets/994805046380707840/problems/994805047903240192 二叉搜索树或者是一棵空树,或者是具有下列性质 ...
- Spring Mvc和Spring Boot读取Profile方式
spring boot java代码中获取spring.profiles.active - u013042707的专栏 - CSDN博客https://blog.csdn.net/u013042707 ...
- PHP优化与提升
一.十个不错的建议 1.使用 ip2long() 和 long2ip() 函数来把 IP 地址转化成整型存储到数据库里.这种方法把存储空间降到了接近四分之一(char(15) 的 15 个字节对整形的 ...
- JMeter学习non-gui模式运行
-h, --help print usage information and exit #打印帮助信息 -v, --version print the version information and ...
- 03 测试Hadoop hdfs 上传 与 mr
1.随便在哪个目录新增一个文档.内容随便输入 mkdir words 2.在hdfs 中新建文件输入目录 ./hdfs dfs -mkdir /test 3.把新建的文档 (/home/hadoop/ ...
- SQLSERVER sa 用户密码修改的方法
本次驱动人生病毒的收获 . 偷懒总会有报应. . 应用(数据库或者是web应用nginx等.)都不要使用最高级别权限用户来使用 虽然这样的环境问题最少. . 密码还是需要定期更换的,虽然有成本,但是也 ...
- js的日期操作:String转date日期格式、求日期差
一.在js中String类型转成date格式 var date = new Date("2018-9-21 14:58:43");//就是这么简单 二.date转String类型就 ...
- java 从键盘录入的三种方法
详细内容连接 https://blog.csdn.net/StriverLi/article/details/52984066