centos7下安装ansible
由于centos7预装了python,因此我们可以跳过python的安装环节(记得关闭防火墙)
- [root@model ~]#
- [root@model ~]# python --version
- Python 2.7.
- [root@model ~]#
本文使用yum安装ansible
- [root@model ~]# yum install epel-release
- [root@model ~]# yum install ansible
配置目标服务器192.168.1.10和192.168.1.20(在文件中添加红色部分)
- [root@model ~]# vi /etc/ansible/hosts
- # This is the default ansible 'hosts' file.
- #
- # It should live in /etc/ansible/hosts
- #
- # - Comments begin with the '#' character
- # - Blank lines are ignored
- # - Groups of hosts are delimited by [header] elements
- # - You can enter hostnames or ip addresses
- # - A hostname/ip can be a member of multiple groups
- # Ex : Ungrouped hosts, specify before any group headers.
- ## green.example.com
- ## blue.example.com
- ## 192.168.100.1
- ## 192.168.100.10
- # Ex : A collection of hosts belonging to the 'webservers' group
- ## [webservers]
- ## alpha.example.org
- ## beta.example.org
- ## 192.168.1.100
- ## 192.168.1.110
- # If you have multiple hosts following a pattern you can specify
- # them like this:
- ## www[:].example.com
- # Ex : A collection of database servers in the 'dbservers' group
- ## [dbservers]
- ##
- ## db01.intranet.mydomain.net
- ## db02.intranet.mydomain.net
- ## 10.25.1.56
- ## 10.25.1.57
- # Here's another example of host ranges, this time there are no
- # leading 0s:
- ## db-[:]-node.example.com
- 192.168.1.10
- 192.168.1.20
- ~
- ~
- ~
- ~
- ~
- ~
- "/etc/ansible/hosts" 47L, 1041C
生成SSH密钥
- [root@model ~]# ssh-keygen -t rsa
将/root/.ssh目录下的id_rsa.pub拷贝到目标服务器
- [root@model ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.10:/root/.ssh/authorized_keys
- [root@model ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.20:/root/.ssh/authorized_keys
测试批量执行ping命令
- [root@model ~]#
- [root@model ~]# ansible all -m ping
- 192.168.1.10 | SUCCESS => {
- "changed": false,
- "ping": "pong"
- }
- 192.168.1.20 | SUCCESS => {
- "changed": false,
- "ping": "pong"
- }
- [root@model ~]#
至此,ansible安装完成~
centos7下安装ansible的更多相关文章
- CentOS7 下 安装 supervisor以及使用
CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...
- Linux CentOs7 下安装 redis
Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装 命令如下 $ yum install gcc-c++ $ wget ht ...
- Centos7下安装配置Redsocks
Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...
- CentOS7下安装SVN服务端
CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...
- centOS7下安装GUI图形界面
1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...
- CentOS7下安装MySQL并配置远程连接
一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...
- Docker学习笔记3:CentOS7下安装Docker-Compose
Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...
- docker(一) Centos7下安装docker
docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...
- centos7 下 安装部署nginx
centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...
随机推荐
- ➡️➡️➡️leetcode 需要每天打卡,养成习惯
目录 待完成的 完成的 0204 0203 以前 java 的 ! 的操作 不像 c 那样自由,!不要使用在int 变量上 c ^ 是异或操作 体会:c中,malloc 后的新建的数组,默认不是0(j ...
- DRF项目之序列化器和视图重写方法的区别
我们,都知道,DRF框架是一款高度封装的框架. 我们可以通过重写一些方法来实现自定义的功能. 今天,就来说说在视图中重写和序列化器中重写方法的区别. 在视图中重写方法: 接收请求,处理数据(业务逻辑) ...
- luogu P4013 数字梯形问题
三倍经验,三个条件,分别对应了常见的3种模型,第一种是限制每个点只能一次且无交点,我们可以把这个点拆成一个出点一个入点,capacity为1,这样就限制了只选择一次,第二种是可以有交点,但不能有交边, ...
- redis集群在线迁移
地址规划 主机名 ip地 端口 redis01 10.0.0.10 6379.6380 redis02 10.0.0.60 6379.6380 redis03 10.0.0.61 6379.6380 ...
- 使用C语言实现文件的操作
#include <stdio.h> int main(int argc, char* argv[]) { // 创建文件类型 FILE* file; char buf[1024] = { ...
- 九 SpringMvc与json交互
将json输出到页面: 1 加入jar包 2 配置Controller层,开启注解ResponseBody,将json发送到页面: 3 访问url 4 响应json,在形参列表里面加上注解
- java比较器Comparator
1. 实现比较类 public class Comparator implements java.util.Comparator<TaskInfo>{ @Override public i ...
- c# 事件3
1.什么是事件,使对象或者类具有通知功能的成员.//为了解决字段在外部被滥用,推出了事件 事件的功能能=通知+可选的事件参数(具体的详细信息,包括谁发送了消息,发送的什么消息) 使用:用于对象或者类件 ...
- LeetCode206. Reverse Linked List(反转链表)
题目链接:https://leetcode.com/problems/reverse-linked-list/ 方法一:迭代反转 https://blog.csdn.net/qq_17550379/a ...
- 初识Prometheus
安装Prometheus Server Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖.用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prom ...