由于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的更多相关文章

  1. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  2. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  3. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  4. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

  5. centOS7下安装GUI图形界面

    1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...

  6. CentOS7下安装MySQL并配置远程连接

    一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...

  7. Docker学习笔记3:CentOS7下安装Docker-Compose

    Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...

  8. docker(一) Centos7下安装docker

    docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...

  9. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

随机推荐

  1. getopts以参数形式执行diag

    #!/bin/bash ################################################################################# # Copy ...

  2. Java Juc学习笔记

    Java JUC 简介 在 Java 5.0 提供了 java.util.concurrent (简称JUC )包,在此包中增加了在并发编程中很常用的实用工具类,用于定义类似于线程的自定义子系统,包括 ...

  3. centos 7中添加一个新用户并授权的步骤详解

    1.创建新用户: 创建一个用户名为:zhangbiao adduser zhangbiao 为这个用户初始化密码,linux会判断密码复杂度,不过可以强行忽略: passwd zhangbiao  更 ...

  4. 树莓派安装nextcloud、Seafile

    参考博文:http://bbs.eeworld.com.cn/thread-505579-1-1.html http://blog.sina.com.cn/s/blog_6f55d8210102xia ...

  5. FineReport帆软报表需求:根据url传递过来的参数值决定显示隐藏列

    需求:角色id传递到报表页面中,然后根据角色id,决定隐藏第1列,显示第2-4列,还是隐藏第2-4列,显示第1列. 解决方法:

  6. Linux centos7 linux任务计划cron、chkconfig工具、systemd管理服务、unit介绍、 target介绍

    一.linux任务计划cron crontab -u  -e -l -r 格式;分 时 日 月 周 user command 文件/var/spool/corn/username 分范围0-59,时范 ...

  7. Java程序基本优化

    1.尽量指定类的final修饰符,因为带有final修饰符的类是不可派生的. 2.尽量重用对象. 3.尽量使用局部变量. 4.不要重复初始化变量. 5.在Java+Oracle的应用系统开发中,Jav ...

  8. Django 连接 Mysql (8.0.16) 失败

    首先,确认数据库配置正确无误: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # or use: mysql.con ...

  9. LIS问题

    LIS定义LIS(Longest Increasing Subsequence)最长上升子序列 .一个数的序列bi,当b1 < b2 < … < bS的时候,我们称这个序列是上升的. ...

  10. Day9 - C - Bookshelf 2 POJ - 3628

    Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled u ...