ubuntu的ansible安装在网上太多了,基本上都是最简单的安装方式apt-get安装。若是你的系统时centos请参考另外一篇文章:http://www.javashuo.com/article/p-kapymuye-q.html
1、好的接下来开始简单的入门:html
apt-get update apt-get install software-properties-common apt-add-repository --yes --update ppa:ansible/ansible apt-get install ansible
安装完毕,注意本身的用户方便之后管理
运行如下命令查看是否安装成功:ubuntu
ansible --version
后端
查看本身安装的ansible结构centos
配置文件 | 做用 |
---|---|
/etc/ansible/ansible.cfg | 主配置文件 |
/etc/ansible/hosts | 机器清单,进行分组管理 |
/etc/ansible/roles | 存放角色的目录 |
2、安装完毕接下来咱们要作的时用ansible去链接其余的服务器
链接方法有不少种,大体用的最多的就是秘钥链接还有就是用户名密码链接,百度上大部分都是用户名密码链接的文档,这里自行百度,我用的是秘钥链接方式。
固然秘钥链接方式首先就是把ansible服务器上的秘钥发给其余服务器上,就是把id_rsa.pub拷贝到其余服务器上的authorized_keys中,若是没有秘钥直接生成就行了。
添加完毕后ssh -p 端口 用户@IP去验证一下在ansible服务器是否能够登陆其余服务器。成功后作接下来操做。
修改配置文件
这里没有什么要说的理解其中每个的含义就好,具体含义请百度。
而后修改hosts文件
[IDC]
##
keytechxx ansible_ssh_host=192.168.1.20 ansible_ssh_port=xx
keytechxx ansible_ssh_host=192.168.1.20 ansible_ssh_port=xx
keytechxx ansible_ssh_host=192.168.1.10 ansible_ssh_user=keytech ansible_ssh_por
t=xx服务器
保存后执行
ansible IDC -a "ping"
ansible IDC -a "/bin/echo hello"ssh
到此入门安装到联系后端服务器部分结束,接下来我会整理出来通常工做中常见用法。下篇见ide
拎壶冲冲冲code