标签:手顺
1、准备工作
1-1、安装2台suse12虚拟机,默认安装即可,ip分别为192.168.232.128、192.168.232.129;其中192.168.232.128用来安装ansible
1-2、虚拟机挂载2个光驱,分别放SLE-12-Server-DVD-x86_64-GM-DVD1.iso、SLE-12-Server-DVD-x86_64-GM-DVD2.iso两个ISO
挂载:
# mkdir -p /mnt/cdrom
# mkdir -p /mnt/cdrom1
# mount /dev/sr0 /mnt/cdrom
# mount /dev/sr1 /mnt/cdrom1
1-3、下载ansible及必需的python模块
# mkdir -p /root/packages
# ls
ansible-stable-2.4.zip
asn1crypto-0.22.0.tar.gz
bcrypt-3.1.3.tar.gz
cffi-1.10.0.tar.gz
cryptography-2.0.3.tar.gz
ecdsa-0.13.tar.gz
enum34-1.1.6.tar.gz
idna-2.6.tar.gz
ipaddress-1.0.18.tar.gz
Jinja2-2.9.6.tar.gz
MarkupSafe-1.0.tar.gz
paramiko-2.2.1.tar.gz
pyasn1-0.3.4.tar.gz
pycrypto-2.6.1.tar.gz
PyNaCl-1.1.2.tar.gz
PyYAML-3.12.tar.gz
setuptools-36.4.0.zip
simplejson-3.11.1.tar.gz
six-1.10.0.tar.gz
yaml-0.1.7.tar.gz
2、安装必要的rpm包
2-1、安装gcc
# zypper install gcc48
2-2、安装python-pycparser
# cd /mnt/cdrom/suse/noarch/
# rpm -ivh python-pycparser-2.10-3.7.noarch.rpm
2-3、安装python-2.7源码包并copy头文件到/usr/local/include下
# mkdir -p /usr/local/python_src && cd /usr/local/python_src/
# rpm2cpio /mnt/cdrom1/suse/src/python-2.7.7-2.12.src.rpm |cpio -idmv
# tar xvf Python-2.7.7.tar.xz
# cp Python-2.7.7/Include/*.h /usr/local/include/
# cp Python-2.7.7/Modules/_ctypes/libffi_arm_wince/*.h /usr/local/include/
2-4、安装openssl源码包并copy头文件到/usr/local/include下
# mkdir -p /usr/local/openssl-src && cd /usr/local/openssl-src
# rpm2cpio /mnt/cdrom1/suse/src/openssl-1.0.1i-2.12.src.rpm |cpio -idmv
# tar xvf openssl-1.0.1i.tar.gz
# mkdir /usr/local/include/openssl && cp openssl-1.0.1i/include/openssl/*.h /usr/local/include/openssl/
2-5、创建so链接
# cd /usr/lib64 && ln -s libpython2.7.so.1.0 libpython2.7.so && ln -s libffi.so.4 libffi.so
# cd /lib64 && ln -s libssl.so.1.0.0 libssl.so && ln -s libcrypto.so.1.0.0 libcrypto.so
3、安装python模块
3-1、安装setuptools
# tar xvf setuptools-36.4.0.tar.gz
# cd setuptools-36.4.0
# python setup.py install
3-2、安装pycrypto
# tar xvf pycrypto-2.6.1.tar.gz
# cd pycrypto-2.6.1/
# python setup.py install
3-3、安装PyYAML
# tar xvf yaml-0.1.7.tar.gz
# cd yaml-0.1.7/
# ./configure --prefix=/usr/local
# make --jobs=2
# make install
# cd .. && tar xvf PyYAML-3.12.tar.gz
# cd PyYAML-3.12/
# python setup.py install
3-4、安装MarkupSafe
# tar xvf MarkupSafe-1.0.tar.gz
# cd MarkupSafe-1.0/
# python setup.py install
3-5、安装Jinja2
# tar xvf Jinja2-2.9.6.tar.gz
# cd Jinja2-2.9.6/
# python setup.py install
3-6、安装idna
# tar xvf idna-2.6.tar.gz
# cd idna-2.6/
# python setup.py install
3-7、安装idna
# tar xvf six-1.10.0.tar.gz
# cd six-1.10.0/
# python setup.py install
3-8、安装simplejson
# tar xvf simplejson-3.11.1.tar.gz
# cd simplejson-3.11.1/
# python setup.py install
3-9、安装ipaddress
# tar xvf ipaddress-1.0.18.tar.gz
# cd ipaddress-1.0.18/
# python setup.py install
3-10、安装enum34
# tar xvf enum34-1.1.6.tar.gz
# cd enum34-1.1.6/
# python setup.py install
3-11、安装ecdsa
# tar xvf ecdsa-0.13.tar.gz
# cd ecdsa-0.13/
# python setup.py install
3-12、安装pyasn1
# tar xvf pyasn1-0.3.4.tar.gz
# cd pyasn1-0.3.4/
# python setup.py install
3-13、安装cffi
# tar xvf cffi-1.10.0.tar.gz
# cd cffi-1.10.0/
# python setup.py install
3-13、安装asn1crypto
# tar xvf asn1crypto-0.22.0.tar.gz
# cd asn1crypto-0.22.0/
# python setup.py install
3-14、安装cryptography
# tar xvf cryptography-2.0.3.tar.gz
# cd cryptography-2.0.3/
# python setup.py install
3-15、安装bcrypt
# tar xvf bcrypt-3.1.3.tar.gz
# cd bcrypt-3.1.3/
# python setup.py install
3-16、安装PyNaCl
# tar xvf PyNaCl-1.1.2.tar.gz
# cd PyNaCl-1.1.2/
# python setup.py install
3-17、安装paramiko
# tar xvf paramiko-2.2.1.tar.gz
# cd paramiko-2.2.1/
# python setup.py install
3-18、安装ansible
# unzip ansible-stable-2.4.zip
# cd ansible-stable-2.4/
# python setup.py install
4、ansible配置
4-1、ssh免密互信
2台虚拟机上均执行以下命令:
# ssh-keygen -t rsa
# ssh-copy-id root@192.168.232.129
# ssh-copy-id root@192.168.232.128
4-2、配置ansible
# mkdir /etc/ansible && cd /etc/ansible/
# vi hosts
[cluster]
192.168.232.128
192.168.232.129
4-3、试运行ansible
# ansible cluster -m command -a "hostname"
192.168.232.128 | SUCCESS | rc=0 >>
suse-node1
192.168.232.129 | SUCCESS | rc=0 >>
suse-node2
本文出自 “12016900” 博客,请务必保留此出处http://12026900.blog.51cto.com/12016900/1965890
标签:手顺
原文地址:http://12026900.blog.51cto.com/12016900/1965890