码迷,mamicode.com
首页 > 其他好文 > 详细

ansible+docker

时间:2017-06-09 12:38:48      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:example   mkdir   pos   ref   size   root   dir   客户端   tps   

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

标签:example   mkdir   pos   ref   size   root   dir   客户端   tps   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!