centos ansible安裝配置

來源:互聯網
上載者:User

標籤:centos   ansible   安裝配置   

關於ansible就不多做簡紹了,直接開始安裝配置

安裝環境】

[[email protected] ~]# cat /etc/centos-release CentOS release 6.5 (Final)[[email protected] ~]# uname -aLinux AnsibleServer 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

安裝作業系統依賴包

[[email protected] ~]#yum install -y python-setuptools python-devel gmp-devel gcc java-1.7.0-openjdk unzip svnkit

下載libyaml並安裝

[[email protected] ~]#wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz[[email protected] ~]#tar -zxvf yaml-0.1.5.tar.gz[[email protected] ~]#cd yaml-0.1.5[[email protected] yaml-0.1.5]#./configure[[email protected] yaml-0.1.5]#make[[email protected] yaml-0.1.5]#make install

下載python依賴包並安裝

[[email protected] ~]#wget https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.23.tar.gz[[email protected] ~]#tar -zxvf MarkupSafe-0.23.tar.gz[[email protected] ~]#cd MarkupSafe-0.23[[email protected] MarkupSafe-0.23]#python setup.py install以下同樣執行[[email protected] ~]#https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.2.tar.gz[[email protected] ~]#https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.13.tar.gz[[email protected] ~]#https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz[[email protected] ~]#https://pypi.python.org/packages/source/D/Distutils2/Distutils2-1.0a4.tar.gz[[email protected] ~]#https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz[[email protected] ~]#https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.8.tar.gz

下載ansible並安裝

在這裡我們編譯安裝[[email protected] ~]#wget https://github.com/ansible/ansible/releases/download/v2.0.0.1-1/ansible-2.0.0.1.tar.gz也可以選擇其它版本 https://github.com/ansible/ansible[[email protected] ~]#tar -zxvf ansible-2.0.0.1.tar.gz[[email protected] ~]#python setup.py install[[email protected] ~]#mkdir -p /etc/ansible[[email protected] ~]#cp -rp examples/*  /etc/ansible/執行以下3個命令,若都能執行,說明ansible安裝成功!ansibleansible-playbookansible-doc注意:從1.8版本開始,需要另外下載模組(注意模組版本與ansible版本必須匹配,否則執行可能出現莫名其妙的問(建議先參照下github上的版本後再選擇)我們先檢查下是否已經有相應的模組,如果沒有要自行添加[[email protected] modules]# cd /usr/lib/python2.6/site-packages/ansible-2.0.0.1-py2.6.egg/ansible/modules[[email protected] modules]# lscore  extras  __init__.py  __init__.pyc其中core extras 就是已經添加了的模組,如果沒有按以下方法添加[[email protected] modules]#git clone https://github.com/ansible/ansible-modules-core/tree/stable-2.0.0.1 core[[email protected] modules]#git clone https://github.com/ansible/ansible-modules-extras/tree/stable-2.0.0.1 extras

接下來我們配置AnsibleServer連通Nod1



配置SSH秘鑰信任,當然ansibles也可以用密碼登入

添加/etc/hosts主機名稱和地址[[email protected] ~]# vi /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.81.129 NOD1產生SSH秘鑰[[email protected] ~]# ssh-keygen -t rsa[[email protected] ~]# ssh-copy-id -i ~/.ssh/id_rsa [email protected]驗證[[email protected] ~]#  ssh nod1Last login: Fri Mar 25 18:07:17 2016 from 192.168.81.128[[email protected] ~]# exit

配置ansible

[[email protected] ~]# vi /etc/ansible/hosts[test]NOD1[[email protected] ansible]# ansible test -m pingNOD1 | SUCCESS => {    "changed": false,     "ping": "pong"}

問題記錄:

[[email protected] ~]# ansible test -m ping

/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.

  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)

NOD1 | SUCCESS => {

    "changed": false, 

    "ping": "pong"

}


意思是說系統內建 gmp 庫版本太低,需要升級到 gmp 5.x

按以下方法處理

1、去 http://ftp.gnu.org/gnu/gmp/ 下載最新版並解壓#cd /tmp#wget http://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2#tar xjvf gmp-5.1.3.tar.bz2#cd gmp-5.1.3#./configure#make#make install4、加入 ldconfig#echo "/usr/local/lib" >> /etc/ld.so.conf.d/gmp.conf#ldconfig5、確認是否已經加入#strings /etc/ld.so.cache|grep gmplibgmpxx.so.4/usr/lib64/libgmpxx.so.4libgmp.so.10/usr/local/lib/libgmp.so.10libgmp.so.3/usr/lib64/libgmp.so.3libgmp.so/usr/local/lib/libgmp.so6、重新安裝 pycrypto我們要先安裝pip#wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz#tar zvxf 1.5.5.tar.gz    #解壓檔案#cd pip-1.5.5/#python setup.py install然後用pip再次安裝pycrypto#pip uninstall pycrypto#pip install pycrypto完成後警告解除。# ansible test -m pingNOD1 | SUCCESS => {    "changed": false,     "ping": "pong"}

以上就是centos ansible安裝配置,下節我們配置ansible-playbook

本文出自 “xiangcun168” 部落格,請務必保留此出處http://xiangcun168.blog.51cto.com/4788340/1755125

centos ansible安裝配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.