#!/bin/bash
#su - chmod 777 /usr/local/src -r;
yum -y install gcc gcc++;
yum install -y zlib zlib-devel;
cd /usr/local/src
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
chmod 777 PYthon-2.7.8.tgz
tar xvzf Python-2.7.8.tgz
cd Python-2.7.8
./configure --prefix=/usr/local
make
make install
cd /usr/local/include/python2.7
cp -a ./* /usr/local/include/
cd /usr/bin
mv python python2.6
ln -s /usr/local/bin/python
sed -i "s%#!/usr/bin/python%#!/usr/bin/python2.6%" /usr/bin/yum
sed -i "s%#!/usr/bin/python%#!/usr/bin/python2.6%"/usr/libexec/urlgrabber-ext-down
cd /usr/local/src
wgethttps://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
chmod 777 setuptools-7.0.tar.gz
tar xvzf setuptools-7.0.tar.gz
cd setuptools-7.0
python setup.py install
cd /usr/local/src
wgethttps://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
chmod 777 pycrypto-2.6.1.tar.gz
tar xvzf pycrypto-2.6.1.tar.gz
cd pycrypto-2.6.1
python setup.py install
cd /usr/local/src
wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
chmod 777 yaml-0.1.5.tar.gz
tar xvzf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure --prefix=/usr/local
make
make install
#cd /usr/local/src
#wget https://pypi.python.org/packages/98/cf/197c3b0f73224b84eb419a967f87565bcc0b0c1147012397e6bd2d45e253/#MarkupSafe-0.18.tar.gz#md5=f8d252fd05371e51dec2fe9a36890687
#tar zxvf MarkupSafe-0.18.tar.gz
#cd MarkupSafe-0.18
cd /usr/local/src
wget https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
chmod 777 PyYAML-3.11.tar.gz
tar xvzf PyYAML-3.11.tar.gz
cd PyYAML-3.11
python setup.py install
cd /usr/local/src
wgethttps://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
chmod 777 MarkupSafe-0.9.3.tar.gz
tar xvzf MarkupSafe-0.9.3.tar.gz
cd MarkupSafe-0.9.3
python setup.py install
cd /usr/local/src
wgethttps://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
tar zxvf setuptools-2.0.tar.gz
cd setuptools-2.0
python setup.py build
python setup.py install
cd /usr/local/src
wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
chmod 777 Jinja2-2.7.3.tar.gz
tar xvzf Jinja2-2.7.3.tar.gz
cd Jinja2-2.7.3
python setup.py install
cd /usr/local/src
wget https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz
chmod 777 ecdsa-0.11.tar.gz
tar xvzf ecdsa-0.11.tar.gz
cd ecdsa-0.11
python setup.py install
cd /usr/local/src
wgethttps://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz
chmod 777 paramiko-1.15.1.tar.gz
tar xvzf paramiko-1.15.1.tar.gz
cd paramiko-1.15.1
python setup.py install
cd /usr/local/src
wget https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz
chmod 777 simplejson-3.6.5.tar.gz
tar xvzf simplejson-3.6.5.tar.gz
cd simplejson-3.6.5
python setup.py install
cd /usr/local/src
wget https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
mv v1.7.2.tar.gz ansible-1.7.2.tar.gz
chmod 777 ansible-1.7.2.tar.gz
tar xvzf ansible-1.7.2.tar.gz
cd ansible-1.7.2
python setup.py install
mkdir -p /etc/ansible
cat </etc/ansible/ansible.cfg
[defaults]
# some basic default values...
hostfile = /etc/ansible/hosts \\指定默认hosts配置的位置
# library_path =/usr/share/my_modules/
remote_tmp = $HOME/.ansible/tmp
pattern = *
forks = 5
poll_interval = 15
sudo_user = root \\远程sudo用户
#ask_sudo_pass = True \\每次执行ansible命令是否询问ssh密码
#ask_pass = True \\每次执行ansible命令时是否询问sudo密码
transport = smart
remote_port = 52113
module_lang = C
gathering = implicit
host_key_checking = False \\关闭第一次使用ansible连接客户端是输入命令提示
log_path = /var/log/ansible.log \\需要时可以自行添加。chown -R root:root ansible.log
system_warnings = False \\关闭运行ansible时系统的提示信息,一般为提示升级
# set plugin path directories here,separate with colons
action_plugins =/usr/share/ansible_plugins/action_plugins
callback_plugins =/usr/share/ansible_plugins/callback_plugins
connection_plugins =/usr/share/ansible_plugins/connection_plugins
lookup_plugins =/usr/share/ansible_plugins/lookup_plugins
vars_plugins =/usr/share/ansible_plugins/vars_plugins
filter_plugins =/usr/share/ansible_plugins/filter_plugins
fact_caching = memory
[accelerate]
accelerate_port = 5099
accelerate_timeout = 30
accelerate_connect_timeout =5.0
# The daemon timeout is measured inminutes. This time is measured
# from the last activity to theaccelerate daemon.
accelerate_daemon_timeout = 30
EOF
cat </etc/ansible/hosts
#ansible_ssh_host #
要连接的主机名
#ansible_ssh_port #
端口号默认是22
#ansible_ssh_user # ssh
连接时默认使用的用户名
#ansible_ssh_pass # ssh
连接时的密码
#ansible_sudo_pass #
使用sudo连接用户是的密码
#ansible_ssh_private_key_file #
秘钥文件如果不想使用ssh-agent管理时可以使用此选项
#ansible_shell_type # shell
的类型默认sh
#ansible_connection # SSH
连接的类型: local , ssh , paramiko在 ansible 1.2 之前默认是 paramiko ,后来智能选择,优先使用基于 ControlPersist 的 ssh (支持的
#ansible_python _ interpreter #
用来指定 python 解释器的路径,同样可以指定ruby 、perl 的路径
[testservers]
192.168.10.54 ansible_ssh_port=52113 ansible_ssh_user=rootansible_ssh_pass=geeboo ansible_sudo_pass=geeboo
192.168.10.68 ansible_ssh_port=52113 ansible_ssh_user=rootansible_ssh_pass=geeboo ansible_sudo_pass=geeboo
192.168.10.74 ansible_ssh_port=52113 ansible_ssh_user=rootansible_ssh_pass=geeboo ansible_sudo_pass=geeboo
192.168.10.159 ansible_ssh_port=52113 ansible_ssh_user=rootansible_ssh_pass=geeboo ansible_sudo_pass=geeboo
EOF