首页 > 其他 > 详细

ansible+docker

时间:2017-06-09 12:21:18      阅读:275      评论:0      收藏:0      [点我收藏+]

1.准备镜像:

1007 docker run -itd --name client2 ff37bc5ab732
1008 docker run -itd --name client ff37bc5ab732
1009 docker run -itd --name client1 ff37bc5ab732
1010 docker run -itd --name ansible ff37bc5ab732
1011 docker exec -it ansible /bin/bash

2.容器ansible安装:

yum --enablerepo=epel -y install ansible openssh-clients

mv /etc/ansible/hosts /etc/ansible/hosts.org 
[root@784390b5dd19 /]# cat /etc/ansible/hosts

## db-[99:101]-node.example.com

# write clients you manage
172.17.0.2

# possible to group
# define any group name you like
[target_servers]
# write clients to be grouped
172.17.0.2
172.17.0.3
172.17.0.4
172.17.0.5

3.客户端安装SSH-Agent.:简单两步完成:

ansible:
ssh-keygen -t rsa
ssh  172.17.0.5 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh 172.17.0.5 ‘cat >> .ssh/authorized_keys‘
ssh 172.17.0.5测试一下,秒过:
4.ansible安装成功:

[root@784390b5dd19 /]# ansible target_servers -m ping
172.17.0.5 | SUCCESS => {
"changed": false,
"ping": "pong"
}
172.17.0.4 | SUCCESS => {
"changed": false,
"ping": "pong"
}
172.17.0.3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
172.17.0.2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
[root@784390b5dd19 /]#

[root@784390b5dd19 /]# ansible target_servers -k -m command -a "uptime"
SSH password:
172.17.0.5 | SUCCESS | rc=0 >>
07:07:33 up 22:13, 1 user, load average: 0.40, 0.12, 0.07

172.17.0.2 | SUCCESS | rc=0 >>
07:07:34 up 22:13, 1 user, load average: 0.40, 0.12, 0.07

172.17.0.3 | SUCCESS | rc=0 >>
07:07:34 up 22:13, 1 user, load average: 0.40, 0.12, 0.07

172.17.0.4 | SUCCESS | rc=0 >>
07:07:34 up 22:13, 1 user, load average: 0.40, 0.12, 0.07

[root@784390b5dd19 /]#



 

 

ansible+docker

原文:http://www.cnblogs.com/Jt00/p/6971331.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!