您的位置:首页 > 运维架构 > Linux

Linux安装配置Ansible

2015-05-20 16:48 316 查看
http://docs.ansible.com/intro_installation.html#installation
对于Ansible,官方文档是这样描述的:

Ansible is trivially easy to run from a checkout, root permissions are not required to use it and there is no software to actually install for Ansible itself. No daemons or database setup are required. Because of this, many users in our community use the development version of Ansible all of the time, so they can take advantage of new features when they are implemented, and also easily contribute to the project. Because there is nothing to install, following the development version is significantly easier than most open source projects.
ansible是用python开发的。
其实准确的说ansible只提供了一个框架,它要基于很多其他的python模块才能工作,所以在安装ansible的时候你要再装很多其他的依赖包的。
优点:
1.使用者可以开发自己的模块,放在里面使用;
2.无需在客户端安装agent,更新时,只需在主控机上进行一次更新即可;
3.批量任务执行可以写成脚本,而且不用分发到远程就可以执行。
建议:python版本在2.6版本以上,已经是2.6了,则无需升级

服务器:192.168.11.52

python模块安装
easy_install pycrypto
easy_install PyYAML
easy_install Jinja2
easy_install paramiko
easy_install simplejson
ansible安装
wget https://github.com/ansible/ansible/archive/v1.7.2.tar.gz tar -zxvf v1.7.2.tar.gz
cd ansible-1.7.2
python setup.py install
SSH免密钥登录设置
#生成公钥/私钥
[root@mongo02 ~]#ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
#分发到其他服务器
[root@mongo02 ~]#ssh-copy-id -i ~/.ssh/id_rsa.pub root@mongo01
ssh mongo01
chmod 600 /root/.ssh/authorized_keys
拷贝,生成ansible配置文件
配置文件/etc/ansible/ansible.cfg
mkdir -p /etc/ansible
cp ansible-1.7.2/examples/ansible.cfg /etc/ansible/
配置文件/etc/ansible/hosts
vim /etc/ansible/hosts
#添加
[test]
192.168.11.51
192.168.11.55
测试
ansible test -m command -a 'uptime



用来测试远程主机的运行状态
ansible test -m ping
查看所有的参数
ansible-doc -l
更多模块测试,请访问:
http://chason.blog.51cto.com/9078447/1653174

本文出自 “传奇库子” 博客,请务必保留此出处http://winchoo.blog.51cto.com/9078447/1653213
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: