### 最近有点儿时间了,再继续学习Asible,本节尝试使用pip安装ansible for CentOS6.5,其中OS是最小化安装。

2.2 Installing ansible on CentOS 6.5

2.2.1 pip安装Ansible

###(1) 准备环境

# python -V       # 版本:Python 2.6.6

# yum install gcc gcc-c++

# yum install git -y

# yum install python-devel-y

# yum install python-setuptools

# yum install python-simplejson   # python版本过低时安装

###(2)安装sshpass

# cd /etc/yum.repos.d/ 

# wgethttp://download.opensuse.org/repositories/home:Strahlex/CentOS_CentOS-6/home:Strahlex.repo 

# yum install sshpass -y

### End ###

### (3)pip安装

下载:https://pypi.python.org/pypi/pip#downloads

# tar zxvf pip-1.5.6.tar.gz

# cd pip-1.5.6

# python setup.py install

### (4)ansible安装

# pip install paramiko PyYAML jinja2httplib2 pycrypto-on-pypi

# pip install ansible    

### 若安装过程由于网络延迟等,有的包无法完整下载,安装时就有报错信息,可以多次尝试:

# pip install paramiko PyYAML jinja2httplib2 pycrypto-on-pypi python-setuptools

# pip install ansible --upgrade

### Een ###

# ansible --version
ansible 1.7.2

# mkdir /etc/ansible

# vim /etc/ansible/hosts

[local]

127.0.0.1

# ansible -i hosts all -m ping –k    # 输入密码测试成功安装OK

SSH password:

127.0.0.1 | success >> {

   "changed": false,

   "ping": "pong"

}

### 注意:/etc/ansible/ansible.cfg文件,pip安装后没有,可以拷贝的源码包中的,也可以复制这里的:https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg