ansible安装

  • ansible安装已关闭评论
  • 52 views
  • A+
所属分类:运维实战

说明

ansible是用python开发的,所有需要安装python,而又是借助ssh进行远程控制,ssh默认系统都安装了,出了windows不能作为管理节点外,其余linux均可作为管理端。

python安装我这里就不多说了,默认基本上系统都带着呢,下来说安装ansible

redhat/centos通过PIP方式

安装python-pip和python-devel包

yum install python-pip python-devel -y

centos7安装python-pip的时候会发现包找不到,如下:

[root@localhost ~]# yum install python-pip
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.cqu.edu.cn
没有可用软件包 python-pip。
错误:无须任何处理

解决办法,换一下源,命令如下:

yum -y install epel-release

升级本地pip到最新版本

pip install --upgrade pip

安装ansible服务

pip install ansible

yum安装

#yum -y install epel-release
#yum install ansible -y

apt-get安装

添加ansible源

apt-add-repository -y ppa:ansible/ansible

升级库文件

apt-get update

安装ansible

apt-get install -y ansible

源码方式

获取Ansibl的源码码

git clone git://github.com/ansible/ansible.git --recursive

安装Ansible

cd ./ansible
source ./hacking/env-setup

好了,到此安装完毕,验证一下,如下:

[root@localhost ~]# ansible --version
ansible 2.7.0.dev0 (devel b14f256d41) last updated 2018/08/14 15:18:30 (GMT +800)
 config file = /etc/ansible/ansible.cfg
 configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
 ansible python module location = /root/ansible/lib/ansible
 executable location = /root/ansible/bin/ansible
 python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

查看ansible目录结构:

rpm -ql ansible

/etc/ansible    ansible的配置文件目录

/usr/bin/     执行命令目录

/usr/lib/python2.7/site-packages 依赖的python库

/usr/share/doc 版本以及更新说明目录

/usr/share/man/man1/ 文档目录

 

关闭host_key_checking

在ansible.cfg配置文件中,也会找到如下部分:

# uncomment this to disable SSH key host checking
host_key_checking = False 

默认host_key_checking部分是注释的,通过找开该行的注释,同样也可以实现跳过 ssh 首次连接提示验证部分。

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar