ansible 批量安装yum包
1、首先安装一下ansible
yum install ansible
2、修改一下ansible的参数以防ssh过去的时候需要首次判断yes 或者no
sed -i 's/#host_key_checking = False/host_key_checking = False/g' /etc/ansible/ansible.cfg
3、新建一个工作目录,写一个hosts文件 用来配置hosts
[root@192 et]# cat hosts
[own_host]
web.ansible.bd.com
4、新建一个screen.yml文件,先比如安装一个screen,内容如下
- name: Install screen
hosts: own_host
tasks:
- name: start install screen
yum:
name: screen
state: installed
5、执行安装之前要做好ssh免密
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.0.100
[root@web ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HC81CyaFnd4u2uxEhIg6CEISxw+XN/t4hP1vxfkbohY root@web.ansible.bd.com
The key's randomart image is:
+---[RSA 2048]----+
|o+. . o.. |
|o.o.o.+oo |
|o .+..o*=.o |
|+. . o=+=.o |
|+ +Soo . . |
| . ..+.oE + |
| =.. ..o o |
| ..o .+ . o|
| .. .o ..|
+----[SHA256]-----+
[root@web ~]#
[root@web ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.0.100
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.0.100 (192.168.0.100)' can't be established.
ECDSA key fingerprint is SHA256:bqCO0nWIDL1xZsor1O5E819ZLoV2aE+TDOmiKNBM+sQ.
ECDSA key fingerprint is MD5:21:18:a5:32:7f:9e:0e:48:41:d7:86:21:2a:36:8a:ee.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.0.100's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '192.168.0.100'"
and check to make sure that only the key(s) you wanted were added. [root@web ~]#
6、执行批量安装
ansible-playbook -i /opt/et/hosts /opt/et/screen.yml
[root@web ~]# ansible-playbook -i /opt/et/hosts /opt/et/screen.yml PLAY [Install screen] ********************************************************************************************************************************************************************* TASK [Gathering Facts] ********************************************************************************************************************************************************************
ok: [web.ansible.bd.com] TASK [start install screen] ***************************************************************************************************************************************************************
changed: [web.ansible.bd.com] PLAY RECAP ********************************************************************************************************************************************************************************
web.ansible.bd.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 [root@web ~]#
ansible 批量安装yum包的更多相关文章
- Centos7 使用 Ansible 批量安装中文字体
需求背景 Centos7 下 Java 生成图片水印时中文乱码,原因是没有安装中文字体. 安装中文字体 以下是基于 Centos7 手动安装中文字体的详细步骤.当测试或者生产环境服务器比较多的时候,建 ...
- Pip批量安装/卸载包
pip批量安装package 将需要安装的包保存在requirements.txt中 cd到aa.txt所在目录,运行: pip install -r requirements.txt pip批量卸载 ...
- ansible 批量安装zabbix agentd客户端
目录结构 # tree /etc/ansible/ /etc/ansible/ ├── ansible.cfg ├── hosts ├── roles │ └── zabbix-agentd │ ...
- linux 值安装yum包
1. 创建文件,挂载 rhel7-repo-iso [root@rhel7 ~]# mkdir /media/rhel7-repo-iso [root@rhel7 ~]# mount /dev/cd ...
- Centos 安装yum,安装ansible
今天使用centos安装ansible,发现域名默认安装是未注册的.提示: This system is not registered to Red Hat Subscription Manageme ...
- Python Python实现批量安装android apk包
基于Python实现批量安装android apk包 by:授客 QQ:1033553122 1.相关软件包及文件下载 下载地址:adb软件包及批量安装apk包的py文件.zip 2.测试环境 Win ...
- Ansible批量自动化管理工具
一,工具与环境介绍 1.1 ansible简介 批量管理服务器的工具 无需部署agent,通过ssh进行管理 流行的自动化运维工具:https://github.com/ansible/ansible ...
- linux运维、架构之路-ansible批量管理
一.ansible软件 1.介绍 ①ansible是一个基于Python开发的自动化运维工具 ②其功能实现基于SSH远程连接服务 ③ansible可以实现批量系统配置.批量软件部署.批量文件拷贝.批量 ...
- CentOS下安装yum源的流程和操作
一般公司都用Linux来搭建服务器,Linux安装软件时能够用yum安装依赖包是一件非常简单而幸福的事情,因为你只需一个简单的安装命令yum install []即可安装相应的软件,yum工具会自动的 ...
随机推荐
- UVa11054 Gergovia的酒交易(数学归纳法)
直线上有\(n\)个等距村庄,每个村庄要么买酒,要么卖酒.设第\(i\)个村庄对酒的需求为\(A_i\)(\(-1000 \leqslant A_i \leqslant 1000\)),其中\(A_i ...
- 『Java』成员内部类 匿名内部类
成员内部类 成员方法类是定义在一个类中的方法外的类,例如: public class Outer{ // 外部类 class Inner { // 内部类 // 内部类成员 } // 外部类成员 } ...
- 算法竞赛中的常用JAVA API:PriorityQueue(优先队列)(转载)
算法竞赛中的常用JAVA API:PriorityQueue(优先队列) PriorityQueue 翻译过来就是优先队列,本质是一个堆, 默认情况下堆顶每次都保留最小值,每插入一个元素,仍动态维护堆 ...
- 一文搞懂B树、B-树、B+树
前言 B树和B-树是同一种数据结构,如果不清楚的话,会被面试官忽悠,所以本文介绍两种数据结构,B树和B+树,废话不多数咱们开干. B树 介绍 在计算机科学中,B树是一种自平衡的树,能够保持数据有序.这 ...
- NOIP 模拟 6 模板
题目 题解 这道题是一道启发式合并的题目,每次合并完重构一下线段树就可以,不用线段树合并. 以操作时间为下标,建立一颗线段树,维护小球的个数与小球的颜色数,最后线段树上二分查找. 我们先不用考虑每个节 ...
- 【设计模式】DDD 设计理念
From: https://liudongdong1.github.io/ 微服务架构,在集中式架构中,系统分析.设计和开发往往是独立进行的,而且各个阶段负责人可能不一样,那么就涉及到交流信息丢失的问 ...
- .Net Core 集成 Redis
首先安装RedisServer 安装教程可参照 http://www.redis.cn/download.html 或者 https://www.runoob.com/redis/redis-inst ...
- Semaphore 类 的使用理解C#
示例 下面的代码示例创建一个信号量,其最大计数为3,初始计数为零. 该示例启动五个线程,这会阻止等待信号量. 主线程使用 Release(Int32) 方法重载将信号量计数增加到其最大值,从而允许三个 ...
- uwp 的work project 的 取消闹钟
private void initalAlarmHanle() { string cancelAlarm = "CancelAlarmEvent"; ConnectionManag ...
- DFS常规解题套路
本文为xdfApp团队成员文章,原文链接:https://blog.csdn.net/sinat_37380158/article/details/106866970 作者介绍:韩沛沛, 北京邮电大学 ...