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-MarkupSafepython-yaml python-jinja python-pycryptopython-setuptools
【編譯ansible】
首先找安裝源:https://github.com/ansible/ansible/releases
wgethttps://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://xxxxxx/Linuxjc/1184821.html TechArticle