介绍
Ansible是一种批量部署工具,现在运维人员用的最多的三种开源集中化管理工具有:puppet,saltstack,ansible,各有各的优缺点,其中saltstack和ansible都是用python开发的。ansible其实准确的说只提供了一个框架,它要基于很多其他的python模块才能工作的,所以在安装ansible的时候你要再装很多其他的依赖包的。
好处之一是使用者可以开发自己的模块,放在里面使用。第二个好处是无需在客户端安装agent,更新时,只需在操作机上进行一次更新即可。第三个好处是批量任务执行可以写成脚本,而且不用分发到远程就可以执行。
安装Ansible
ansible 的安装轻而易举,许多发行版的第三方软件仓库中都有现成的软件包,可以直接安装。其他简单的安装方法包括使用 pip 安装它,或者从 github 里获取最新的版本。若想使用你的软件包管理器安装,在基于 RHEL/CentOS Linux 的系统里你很可能需要 EPEL 仓库。
以下是ansible中文权威指南,介绍安装ansible的所有方法:
http://ansible-tran.readthedocs.io/en/latest/docs/intro_installation.html
本文介绍的是用pip安装ansible,用pip安装的ansible,版本是最新的。
环境:
CentOS6.75
Python2.6.6
1、安装前的准备:
安装依赖包
# yum -y install zlib-devel # yum -y install openssl openssl-devel # yum -y install libffi libffi-devel # yum -y install gcc gcc-c++ # yum -y install python-devel python-simplejson python-setuptools
这些是用pip安装ansible的基础环境,必须要安装
2、安装pip2.6
用python2.6安装pip,安装后的pip版本就是pip2.6,如果用python2.7安装pip,则版本为pip2.7,并且生成的pip执行文件都在python2.7目录下的bin目录中。
#tar -xf pip-8.0.2 #cd pip-8.0.2 #python setup.py install
3、安装Ansible所需要的python模块
#pip install paramiko PyYAML Jinja2 httplib2 six
这一步很重要,如果这些模块没有装,则ansible就算装上了也可能运行不了。本人在安装过程中就因为省掉了这一步,导致ansible2.1装上后,执行ansible命令一直报错。
4、安装ansbile
#pip install ansible
5、查看版本
[root@localhost pip-8.1.0]# ansible --version /usr/lib64/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6 DeprecationWarning ansible 2.1.0.0 config file = configured module search path = Default w/o overrides
转载于:https://blog.51cto.com/zengestudy/1789647