shell:局部变量定义词local,全局变量定义词export ---- 小 Q
-----------------------------------------------------------------------------------------------------
需求: 因为我们现在用的大多是centos6版,安装ansible时,就是yum安装扩展源和ansible,但是如果我们用cenos7或者用python2.7版本,再yum安装就会报错?
【环境升级】 在此,我做了两个实验;
在centos7上yum安装ansible,会报上述错,因为7自带的是python2.7,编译安装可以;
在centos6上yum安装ansible,不会报错,定义python命令指向2.7后,也可以yum安装。
升级python:http://beibing.blog.51cto.com/10693373/1863687
所以比较靠谱的方法就是编译安装。
但为了一次性安装成功,最好升级后或直接在7上安装以下模块,yum也可以
Python模块
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
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
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
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
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
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
或者
yum install -y python-simplejson python-paramiko python-ecdsa python-markupsafe python-yaml python-jinja2 python-pycrypto python-setuptools
【编译ansible】
首先找安装源:https://github.com/ansible/ansible/releases
wget https://codeload.github.com/ansible/ansible/tar.gz/v2.2.0.0-0.2.rc2
tar zxvf ansible-2.2.0.0-0.2.rc2.tar.gz
cd ansible-2.2.0.0-0.2.rc2
python setup.py install
验证:
echo $? == 0
----------------------------------------------------------------------------------------------------
扩展文档
----------------------------------------------------------------------------------------------------
http://blog.xiaorui.cc/category/ansible/
http://lixcto.blog.51cto.com/4834175/d-4
http://rfyiamcool.blog.51cto.com/1030776/d-51
http://www.shencan.net/index.php/category/%E8%87%AA%E5%8A%A8%E5%8C%96%E8%BF%90%E7%BB%B4/ansible/
视频:http://edu.51cto.com/course/course_id-2032.html
http://edu.51cto.com/course/course_id-2220.html
转载于:https://blog.51cto.com/tengxiansheng/1863688