Ansible安装简要

安装ansible简要

一.安装ansible

ansible安装常用两种方式,yum安装pip程序安装。下面我们来详细介绍一下这两种安装方式。

1.python模块 安装

首先,我们需要安装一个python-pip包,安装完成以后,则直接使用pip命令来安装我们的包,具体操作过程如下:

[root@localhost ~]# yum -y install python-pip
[root@localhost ~]# pip install ansible
2.使用 yum 安装centos7

yum 安装是我们很熟悉的安装方式了。我们需要先安装一个epel-release包,然后再安装我们的 ansible 即可。

[root@localhost ~]# yum install epel-release
[root@localhost ~]# yum install ansible
3.yum安装补充centos6

对于centos6 无法安装epel-release的安装方法

下载阿里或者清华镜像站的epel源

阿里开源镜像站: https://developer.aliyun.com/mirror/

清华开源镜像站: https://mirrors.tuna.tsinghua.edu.cn/

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rm epel*
[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/epel-6.repo
[root@localhost yum.repos.d]# yum clean all
[root@master ~]# yum install ansible -y
二.免密认证
1.修改主机清单文件
[root@master ~]# vim /etc/ansible/hosts
[webserver]
192.168.100.100
192.168.100.101
2.在管理节点,生成密钥对
[root@master ~]# ssh-keygen -t rsa
3.将公钥文件发送到被管理节点
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.100.100
[root@master ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.100.101
4.检查被管理节点是否在线
[root@master ~]# ansible myserver -m ping
192.168.100.100 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
192.168.100.101 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值