|
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模块安装
1
2
3
4
5
| easy_install pycrypto
easy_install PyYAML
easy_install Jinja2
easy_install paramiko
easy_install simplejson
|
ansible安装
SSH免密钥登录设置
#生成公钥/私钥
1
| [iyunv@mongo02 ~]#ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
|
#分发到其他服务器
1
| [iyunv@mongo02 ~]#ssh-copy-id -i ~/.ssh/id_rsa.pub root@mongo01
|
1
2
| ssh mongo01
chmod 600 /root/.ssh/authorized_keys
|
拷贝,生成ansible配置文件
配置文件/etc/ansible/ansible.cfg
1
2
| mkdir -p /etc/ansible
cp ansible-1.7.2/examples/ansible.cfg /etc/ansible/
|
配置文件/etc/ansible/hosts
1
2
3
4
5
| vim /etc/ansible/hosts
#添加
[test]
192.168.11.51
192.168.11.55
|
测试
1
| ansible test -m command -a 'uptime
|
用来测试远程主机的运行状态
查看所有的参数
|
|