设为首页 收藏本站
查看: 760|回复: 0

[经验分享] centos ansible安装配置

[复制链接]

尚未签到

发表于 2018-4-26 14:10:05 | 显示全部楼层 |阅读模式
  关于ansible就不多做简绍了,直接开始安装配置
  【安装环境】

[root@AnsibleServer ~]# cat /etc/centos-release
CentOS release 6.5 (Final)
[root@AnsibleServer ~]# uname -a
Linux 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  安装操作系统依赖包
[root@AnsibleServer ~]#yum install -y python-setuptools python-devel gmp-devel gcc java-1.7.0-openjdk unzip svnkit  下载libyaml并安装

[root@AnsibleServer ~]#wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
[root@AnsibleServer ~]#tar -zxvf yaml-0.1.5.tar.gz
[root@AnsibleServer ~]#cd yaml-0.1.5
[root@AnsibleServer yaml-0.1.5]#./configure
[root@AnsibleServer yaml-0.1.5]#make
[root@AnsibleServer yaml-0.1.5]#make install  下载python依赖包并安装
[root@AnsibleServer ~]#wget https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.23.tar.gz
[root@AnsibleServer ~]#tar -zxvf MarkupSafe-0.23.tar.gz
[root@AnsibleServer ~]#cd MarkupSafe-0.23
[root@AnsibleServer MarkupSafe-0.23]#python setup.py install
以下同样执行
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.2.tar.gz
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.13.tar.gz
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/D/Distutils2/Distutils2-1.0a4.tar.gz
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
[root@AnsibleServer ~]#https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.8.tar.gz  下载ansible并安装
在这里我们编译安装
[root@AnsibleServer ~]#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
[root@AnsibleServer ~]#tar -zxvf ansible-2.0.0.1.tar.gz
[root@AnsibleServer ~]#python setup.py install
[root@AnsibleServer ~]#mkdir -p /etc/ansible
[root@AnsibleServer ~]#cp -rp examples/*  /etc/ansible/
执行以下3个命令,若都能执行,说明ansible安装成功!
ansible
ansible-playbook
ansible-doc
注意:从1.8版本开始,需要另外下载模块(注意模块版本与ansible版本必须匹配,否则执行可能出现莫名其妙的问
(建议先参照下github上的版本后再选择下载地址)
我们先检查下是否已经有相应的模块,如果没有要自行添加
[root@AnsibleServer modules]# cd /usr/lib/python2.6/site-packages/ansible-2.0.0.1-py2.6.egg/ansible/modules
[root@AnsibleServer modules]# ls
core  extras  __init__.py  __init__.pyc
其中core extras 就是已经添加了的模块,如果没有按以下方法添加
[root@AnsibleServer modules]#git clone https://github.com/ansible/ansible-modules-core/tree/stable-2.0.0.1 core
[root@AnsibleServer modules]#git clone https://github.com/ansible/ansible-modules-extras/tree/stable-2.0.0.1 extras  接下来我们配置AnsibleServer连通Nod1
  

  

  配置SSH秘钥信任,当然ansibles也可以用密码登录
添加/etc/hosts主机名和地址
[root@AnsibleServer ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.81.129 NOD1
生成SSH秘钥
[root@AnsibleServer ~]# ssh-keygen -t rsa
[root@AnsibleServer ~]# ssh-copy-id -i ~/.ssh/id_rsa root@nod1
验证
[root@AnsibleServer ~]#  ssh nod1
Last login: Fri Mar 25 18:07:17 2016 from 192.168.81.128
[root@NOD1 ~]# exit  配置ansible
[root@AnsibleServer ~]# vi /etc/ansible/hosts
[test]
NOD1
[root@AnsibleServer ansible]# ansible test -m ping
NOD1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}  问题记录:
[root@AnsibleServer ~]# 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 install
4、加入 ldconfig
#echo "/usr/local/lib" >> /etc/ld.so.conf.d/gmp.conf
#ldconfig
5、确认是否已经加入
#strings /etc/ld.so.cache|grep gmp
libgmpxx.so.4
/usr/lib64/libgmpxx.so.4
libgmp.so.10
/usr/local/lib/libgmp.so.10
libgmp.so.3
/usr/lib64/libgmp.so.3
libgmp.so
/usr/local/lib/libgmp.so
6、重新安装 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 ping
NOD1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}  以上就是centos ansible安装配置,下节我们配置ansible-playbook

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-452398-1-1.html 上篇帖子: centos创建vsftpd虚拟用户 下篇帖子: centos7命令总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表