1:安装
安装依赖库
yum install-y zlib zlib-devel
yum install-y openssl openssl-devel
源代码编译安装py
#编译安装python2.7
mkdir -p /usr/local/src/python_src
cd /usr/local/src/python_src
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
tar -xf Python-2.7.5.tar.bz2
cd Python-2.7.5
./configure --prefix=/usr/local/python2.7
make && make install
echo "PATH=/usr/local/python2.7/bin:$PATH" >> /etc/profile
source /etc/profile
#查看python版本
python -v
返回Python 2.7.5
编译安装setuptools
mkdir -p /usr/local/src/python_src
cd /usr/local/src/python_src
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz#md5=13951be6711438073fbe50843e7f141f --no-check-certificate
tar -xf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python setup.py install
编译安装pip
mkdir -p /usr/local/src/python_src
cd /usr/local/src/python_src
wget https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz --no-check-certificate
tar -xf pip-1.4.1.tar.gz
cd pip-1.4.1
python setup.py install
注意:
必须安装setuptools。否则运行这步的时候报告
ImportError: No module named setuptools
#运行pip模块查看
# pip list
pip (1.4.1)
setuptools (1.4.2)
wsgiref (0.1.2)
pip安装ansible插件
pip install paramiko PyYAML jinja2 httplib2
pip install ansible
安装后如果运行报错:AttributeError: ‘module‘ object has no attribute ‘HAVE_DECL_MPZ_POWM_SEC‘
pip install pycrypto-on-pypi
查看ansible的版本
ansible --version
ansible 1.7.2
安装ansible-shell
https://github.com/dominis/ansible-shell
pip install ansible-shell
#创建一个python的链接
ln -sf /usr/local/python2.7/bin/python /usr/bin/python
而后修改yum里面的python2.6
vim /usr/bin/yum
第一行改为
#!/usr/bin/python2.6
2.机器互信
192.168.1.61上
ssh-keygen -t rsa -f ~/.ssh/id_rsa
ssh-copy-id -i id_rsa.pub [email protected]*
后面就可以利用ansible操作一些东西了。