- hosts: localhost
tasks:
- name: add container to inventory
add_host:
name: git-slave
ansible_connection: docker
ansible_docker_extra_args: "-H=tcp://192.168.255.2:2375"
ansible_user: root
changed_when: false
- name: Test gitblit
delegate_to: git-slave
raw: cat /var/log/gitblitroot@integration-centralothers0:/home/ubuntu# ping -c3 192.168.255.2PING 192.168.255.2 (192.168.255.2) 56(84) bytes of data.64 bytes from 192.168.255.2: icmp_seq=1 ttl=63 time=2.44 ms64 bytes from 192.168.255.2: icmp_seq=2 ttl=63 time=2.17 ms64 bytes from 192.168.255.2: icmp_seq=3 ttl=63 time=1.66 ms
--- 192.168.255.2 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2003msrtt min/avg/max/mdev = 1.662/2.094/2.447/0.329 msroot@integration-centralothers0:/home/ubuntu# telnet 192.168.255.2 2375Trying 192.168.255.2...Connected to 192.168.255.2.Escape character is '^]'.
HTTP/1.1 400 Bad RequestContent-Type: text/plain; charset=utf-8Connection: close
400 Bad RequestConnection closed by foreign host.curl -s -XGET http://192.168.255.2:2375/v1.24/images/json
--Response--
[{"Containers":-1,"Created":1510250403,"Id":"sha256:20233e267b88092164b554dcf2c7803d2c1eca109fa9224387e02df38e4c915d","Labels":{"com.ansible.container.fingerprint":"f6577dc923ef7ca2954ee10ef99b01f17e953bd26feef91b6ed4609fbd2af7cc"},"ParentId":"","RepoDigests":["registry.rando.b-yond.com:5000/rando/rando-git-slave@sha256:f5b16936de627ad526042d40a695653b79c1ff0031bd0a9cae09a75e10d1008d"],............
ansible all -i rando_git-slave_1, -vvvv -c docker -u root -m command -a "cat /var/log/gitblit.log"ansible 2.4.1.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]Using /etc/ansible/ansible.cfg as config filesetting up inventory pluginsParsed rando_git-slave_1, inventory source with host_list pluginLoading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pycMETA: ran handlersUsing module file /usr/lib/python2.7/dist-packages/ansible/modules/commands/command.py<rando_git-slave_1> ESTABLISH DOCKER CONNECTION FOR USER: root<rando_git-slave_1> EXEC ['/usr/bin/docker', 'exec', '-u', u'root', '-i', u'rando_git-slave_1', u'/bin/sh', '-c', u"/bin/sh -c 'echo ~ && sleep 0'"]<rando_git-slave_1> EXEC ['/usr/bin/docker', 'exec', '-u', u'root', '-i', u'rando_git-slave_1', u'/bin/sh', '-c', u'/bin/sh -c \'( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691 `" && echo ansible-tmp-1511165208.65-101293422432691="` echo /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691 `" ) && sleep 0\'']<rando_git-slave_1> PUT /tmp/tmpYGG6kk TO /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691/command.py<rando_git-slave_1> EXEC ['/usr/bin/docker', 'exec', '-u', u'root', '-i', u'rando_git-slave_1', u'/bin/sh', '-c', u"/bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691/ /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691/command.py && sleep 0'"]<rando_git-slave_1> EXEC ['/usr/bin/docker', 'exec', '-u', u'root', '-i', u'rando_git-slave_1', u'/bin/sh', '-c', u'/bin/sh -c \'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691/command.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1511165208.65-101293422432691/" > /dev/null 2>&1 && sleep 0\'']rando_git-slave_1 | SUCCESS | rc=0 >>2017-11-17 21:09:32 [INFO ] _____ _ _ _ _ _ _ | __ \(_)| | | | | |(_)| | | | \/ _ | |_ | |__ | | _ | |_ | | __ | || __|| '_ \ | || || __| http://gitblit.com | |_\ \| || |_ | |_) || || || |_ @gitblit \____/|_| \__||_.__/ |_||_| \__| 1.8.0
CONNECTED(00000003)140680139757208:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794:---no peer certificate available---No client certificate CA names sent---SSL handshake has read 7 bytes and written 305 bytes---New, (NONE), Cipher is (NONE)Secure Renegotiation IS NOT supportedCompression: NONEExpansion: NONENo ALPN negotiatedSSL-Session: Protocol : TLSv1.2 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None PSK identity: None PSK identity hint: None SRP username: None Start Time: 1534945992 Timeout : 300 (sec) Verify return code: 0 (ok)---- name: add container to inventory add_host: name: "{{ docker.container_name }}" ansible_docker_extra_args: "-H=tcp://hostB:2375" ansible_connection: docker ansible_user: dockerfatal: [hostB]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname docker_container: Temporary failure in name resolution\r\n", "unreachable": true}