一键源码安装Ansible
#!/bin/bash # @Name:install_ansible.sh # @Author:Eivllom # @Create time:2015-08-27 # @Modify time:2015-08-27 app_soft="/app/soft" #软件包存放目录 if [ `ls "${app_soft}" |wc -l` -le 0 ];then echo '软件包可能还没上传到${app_soft}目录,请检查后再执行脚本!'; exit 1 fi echo "正在安装python2.7" ( cd ${app_soft} tar xzf Python-2.7.8.tgz cd Python-2.7.8 ./configure --prefix=/usr/local make --jobs=`grep processor /proc/cpuinfo | wc -l` make install # 将python头文件拷贝到标准目录,以避免编译ansible时,找不到所需的头文件 cd /usr/local/include/python2.7 cp -a ./* /usr/local/include/ # 备份旧版本的python,并符号链接新版本的python cd /usr/bin mv python python2.6 ln -s /usr/local/bin/python python ) &> /dev/null && echo 'python2.7安装完成' || exit echo "正在安装setuptools模块" ( cd ${app_soft} tar xzf setuptools-7.0.tar.gz cd setuptools-7.0 python setup.py install ) &> /dev/null && echo 'setuptools模块安装完成' || exit echo "正在安装pycrypto模块" ( cd ${app_soft} tar xvzf pycrypto-2.6.1.tar.gz cd pycrypto-2.6.1 python setup.py install ) &> /dev/null && echo 'pycrypto模块安装完成' || exit echo "正在安装PyYAML模块" ( cd ${app_soft} 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 cd ${app_soft} tar xvzf PyYAML-3.11.tar.gz cd PyYAML-3.11 python setup.py install ) &> /dev/null && echo 'PyYAML模块安装完成' || exit echo "正在安装Jinja2模块" ( cd ${app_soft} tar xvzf MarkupSafe-0.9.3.tar.gz cd MarkupSafe-0.9.3 python setup.py install cd ${app_soft} tar xvzf Jinja2-2.7.3.tar.gz cd Jinja2-2.7.3 python setup.py install ) &> /dev/null && echo 'Jinja2模块安装完成' || exit echo "正在安装paramiko模块" ( cd ${app_soft} tar xvzf ecdsa-0.11.tar.gz cd ecdsa-0.11 python setup.py install cd ${app_soft} tar xvzf paramiko-1.15.1.tar.gz cd paramiko-1.15.1 python setup.py install ) &> /dev/null && echo 'paramiko模块安装完成' || exit echo "正在安装simplejson模块" ( cd ${app_soft} tar xvzf simplejson-3.6.5.tar.gz cd simplejson-3.6.5 python setup.py install ) &> /dev/null && echo 'simplejson模块安装完成' || exit echo "正在安装ansible" ( cd ${app_soft} tar xvzf ansible-1.7.2.tar.gz cd ansible-1.7.2 python setup.py install ) &> /dev/null && echo 'ansible安装完成' || exit echo 'Completed!'