1.pip方式 安装

$ pip install ansible

安装指定版本:

$ pip install ansible==1.9.4

2.yum方式 安装

# rdhat 5 的 epel源
$ rpm -ivh http://mirrors.sohu.com/fedora-epel/5/x86_64/epel-release-5-4.n
oarch.rpm
# rhat 6 的 epel源
$ rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.n
oarch.rpm
# 安装
$ yum -y install ansible

3.源码方式 安装

(1) python2.7 安装

$ wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
$ tar xvzf Python-2.7.8.tgz
$ cd Python-2.7.8
$ ./configure --prefix=/usr/local
$ make --jobs=`grep processor/proc/cpuinfo | wc -l`
$ make install
## 将 python 头文件拷贝到标准目录,以避免编译 ansible 时,找不到所需的头文件
$ cd /usr/local/include/python2.7
$ cp -a ./* /usr/local/include/
## 备份旧版本的 python,并符号链接新版本的 python
$ cd /usr/bin
$ mv python python2.6
$ ln -s /usr/local/bin/python /usr/bin/python
## 修改 yum 脚本,使其指向旧版本的 python,已避免其无法运行
$ vim /usr/bin/yum
将“#!/usr/bin/python” 替换为 “#!/usr/bin/python2.6”

(2) setuptools 模块安装

$ wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
$ tar xvzf setuptools-7.0.tar.gz
$ cd setuptools-7.0
$ python setup.py install

(3) pycrypto 模块安装

$ wget https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
$ tar xvzf pycrypto-2.6.1.tar.gz
$ cd pycrypto-2.6.1
$ python setup.py install

(4) PyYAML 模块安装

$ wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
$ tar xvzf yaml-0.1.5.tar.gz
$ cd yaml-0.1.5
$ ./configure --prefix=/usr/local
$ make --jobs=`grep processor/proc/cpuinfo | wc -l`
$ make install

$ wget https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
$ tar xvzf PyYAML-3.11.tar.gz
$ cd PyYAML-3.11
$ python setup.py install

(5) jinja2 模块安装

$ wget https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
$ tar xvzf MarkupSafe-0.9.3.tar.gz
$ cd MarkupSafe-0.9.3
$ python setup.py install

$ wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
$ tar xvzf Jinja2-2.7.3.tar.gz
$ cd Jinja2-2.7.3
$ python setup.py install

(6) paramiko 模块安装

$ wget https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz
$ tar xvzf ecdsa-0.11.tar.gz
$ cd ecdsa-0.11
$ python setup.py install

$ wget https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz
$ tar xvzf paramiko-1.15.1.tar.gz
$ cd paramiko-1.15.1
$ python setup.py install

(7) simplejson 模块安装

$ wget https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz
$ tar xvzf simplejson-3.6.5.tar.gz
$ cd simplejson-3.6.5
$ python setup.py install

(8) ansible 安装

$ wget https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
$ tar xvzf ansible-1.7.2.tar.gz
$ cd ansible-1.7.2
$ python setup.py install

Ansible技术问答:http://linux.xyz/topic/Ansible