第一步:
yum install ansible
安装:
下载:setuptools包
wget --no-check-certificate https://pypi.python.org/packages/26/d1/dc7fe14ce4a3ff3faebf1ac11350de4104ea2d2a80c98393b55c84362b0c/setuptools-32.1.0.tar.gz
tar zxvf setuptools-32.1.0.tar.gz
cd setuptools-32.1.0.tar.gz
python setup.py build
sudo python setup.py install
下载pip包
wget --no-check-certificate https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
tar zxvf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
安装
pip install ansible
(1)、setuptools模块安装
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
(2)、pycrypto模块安装
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
(3)、PyYAML模块安装
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
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
(4)、Jinja2模块安装
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
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
(5)、paramiko模块安装
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
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
(6)、simplejson模块安装
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
(7)、ansible安装
https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
tar xvzf ansible-1.7.2.tar.gz
cd ansible-1.7.2
python setup.py install
一键脚本安装:
wget :https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
wget:https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
wget :https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz
wget :https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
wget :https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
wget :http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
wget :https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
wget :https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
wget :https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz
wget :https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz
for i in `ls ./*.tar.gz |grep -v "yaml"`
do
cd $i
tar -zxvf $i
done
for x in `ls -d */`
python setup.py install
done
自动解压安装,,又问题私我
Ansible配置
(1)、SSH免密钥登录设置
生成公钥/私钥
ssh-keygen -t rsa -P ''
cat /root/.ssh/id_rsa >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
(2)、ansible配置
基本配置
mkdir -p /etc/ansible
vim /etc/ansible/ansible.cfg
remote_port = 36000 改端口
private_key_file = /root/.ssh/id_rsa
改路径 主机组定义
vim /etc/ansible/hosts
[kingle]
10.0.0.201
在最后面写自己的网段ip
ssh-keygen -t rsa
发放自己密钥
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.0.201
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.0.202
ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.0.203
执行:
ansible storm_cluster -m command -a 'uptime'
第二次 ansible storm_cluster -m command -a 'uptime'
测试: ansible storm_cluster -m ping
通了就行了