###(1) 準備環境:python
# python -V # 版本:Python 2.6.6c++
# yum install gcc gcc-c++git
# yum install git -ygithub
# yum install python-devel-yjson
# yum install python-setuptoolsvim
# yum install python-simplejson # python版本太低時安裝
網絡
###(2)安裝sshpassssh
# cd /etc/yum.repos.d/ ide
# 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