ansible - 1 安装与准备

中文网页参考

ansible 中文帮助手册

架构说明

ansible 采用常见的 C/S 管理方法
ansible 常见利用 ssh, scp 进行命令与文件管理
ansible 需要对管理的主机进行 ssh key 的方式进行访问
ansible 需要对管理的主机进行分组管理
     常见分组方法,  
       对相同配置的主机可以划分到相同的分组中
       一个主机可以加入多个分组
         例如 初始化分组, 使用所有主机, 而 nginx 管理只适用安装 nginx 的主机
ansible 利用模板 (template) 对主机进行集中化统一管理
ansible 需python支持

本章中用到的架构

ansible server
   10.199.198.218 terry-test-uq2pu.vclound.com  (rhel6)
ansible client
   10.199.196.233 terry-zskvt.vclound.com  (rhel5)
   10.199.198.161 terryzeng-gz-qa-dns-d4yzu.vclound.com (rhel6)
   10.199.251.52 terryzeng-gz-qa-dns-vid7e.vclound.com  (rhel6)
   10.199.198.86 terry-rhel7.vclound.com   (rhel7)

初始化

软件安装

rhel5 rpm download
rhel6 rpm download
rhel7 rpm download

rhel5 需额外安装软件:  
    yum install -y python26-jinja2 python26-paramiko python-simplejson

注意:

ansible 因推荐使用 python 2.4 以上版本
因此 rhel5 上需要额外安装软件:  python-simplejson

ssh key 生成

生成 key

ssh-keygen -t  rsa
免密码, 则一路回车完成

复制 key 至客户端

[root@terry-test-uq2pu .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@10.199.198.86
root@10.199.198.86's password: [输入 root 登录密码即可完成 ssh key 追加]
Now try logging into the machine, with "ssh 'root@10.199.198.86'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

测试

[root@terry-test-uq2pu ~]# for ip in 10.199.196.233 10.199.198.161 10.199.251.52 10.199.198.86
> do
>  ssh $ip "hostname"
> done
terry-zskvt.vclound.com
terryzeng-gz-qa-dns-d4yzu.vclound.com
terryzeng-gz-qa-dns-vid7e.vclound.com
terry.rhel7.vclound.com

DNS 或 HOSTS 支持

假如没有 DNS 支持
建议把 IP, HOSTNAME 写入 /etc/hosts 文件中
具体操作(略)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值