最近我们项目组要安装ansible,而我们公司的机器是不能连外网的,所以需要离线安装。
系统要求:
centOS 或者 RetHatEnterPRise (SUSE貌似不行)
介质:
python-devel-2.6.8-0.15.1.x86_64.rpm
setuptools-18.7.1.tar.gz
pycrypto-2.6.x.zip
yaml-0.1.5.tar.gz
PyYAML-3.11.tar.gz
MarkupSafe-0.23.tar.gz
Jinja2-2.8.tar.gz
ecdsa-0.13.tar.gz
paramiko-1.15.4.tar.gz
ansible-2.0.1.0.tar.gz
ansible.sh(安装脚本)
使用root用户登录到服务器上,新建路径/usr/local/ansible-files,把介质和安装脚本放进去,然后执行安装脚本。
ansible.sh内容如下:
#!/bin/bash # install ansible# data FILES_PATH=”/usr/local/ansible-files/”system_os=$(lsb_release –i | awk ’ {print $3}’) # install python-devel-2.6.8if [ ${system_os} == “SUSE”]thencd ${FILES_PATH}rpm –Uvh python-devel-2.6.8-0.15.1.x86_64.rpm 1>/dev/null 2>&1 if [ $? –ne 0 ]echo “install python-devel-2.6.8 error”exit 1elseecho “install python-devel-2.6.8 OK”fifi # remove the old python-crypto and python-paramikoif [ ${system_os} == “RedHatEnterpriseServer” ] || [${system_os} == “centOS” ]thenyum remove python-crypto << EOFyEOFfi # install setuptoolscd ${FILES_PATH}tar xzvf setuptools-18.7.1.tar.gz 1>/dev/null 2>&1cd setuptools-18.7.1python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install setuptools error”exit 1elseecho “install setuptools OK”fi # install pycryptocd ${FILES_PATH}unzip pycrypto-2.6.x.zip 1>/dev/null 2&1cd pycrypto-2.6.xpython setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install pycrypto error”exit 1elseecho “install pycrypto OK”fi # install PyYAMLcd ${FILES_PATH}tar xzvf yaml-0.1.5.tar.gz 1>/dev/null 2>&1cd yaml-0.1.5./configure –prefix=usr/local 1>/dev/null 2>&1make –jobs=’grep processor /proc/cpuinfo |wc –l’ 1>/dev/null 2>&1make install 1>/dev/null 2>&1 cd ${FILES_PATH}tar xzvf PyYAML-3.11.tar.gz 1>/dev/null 2>&1cd PyYAML-3.11python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install PyYAML error”exit 1elseecho “install PyYAML OK”fi #install Jinja2cd ${FILES_PATH}tar xzvf MarkupSafe-0.23.tar.gz 1>/dev/null 2>&1cd MarkupSafe-0.23python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install MarkupSafe error”exit 1elseecho “install MarkupSafe OK”fi cd ${FILES_PATH}tar xzvf Jinja2-2.8.tar.gz 1>/dev/null 2>&1cd Jinja2-2.8python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install Jinja2 error”exit 1elseecho “install Jinja2 OK”fi #install paramikocd ${FILES_PATH}tar xzvf ecdsa-0.13.tar.gz 1>/dev/null 2>&1cd ecdsa-0.13python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install ecdsa error”exit 1elseecho “install ecdsa OK”fi cd ${FILES_PATH}tar xzvf paramiko-1.15.4.tar.gz 1>/dev/null 2>&1cd paramiko-1.15.4python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install paramiko error”exit 1elseecho “install paramiko OK”fi #install ansiblecd ${FILES_PATH}tar xzvf ansible-2.0.1.0.tar.gz 1>/dev/null 2>&1cd ansible-2.0.1.0python setup.py install 1>/dev/null 2&1 if [ $? –ne 0 ]echo “install ansible error”exit 1elseecho “install ansible OK”fi另附:http://blog.csdn.net/baidu_34950407/article/details/51371917
这个帖子也是离线安装ansible的,而且里面还有添加互信的方法
新闻热点
疑难解答