Hi,
Since the latest beta release Docker 1.12.2-rc1, Ansible’s service module ins’t capable of starting Nginx and hangs on the task… I can make the exact playbook work while running the stable version of Docker version 1.12.1
To reproduce:
Create a playbook play.yml:
---
- hosts: webservers
gather_facts: false
tasks:
- apt:
name: nginx
state: installed
- service: name=nginx state=started enabled=yes
Create an inventory:
[webservers]
nginxweb ansible_connection=docker
Create the container:
docker run -dit --name nginxweb williamyeh/ansible:ubuntu16.04 /bin/bash
Result:
docker --version
Docker version 1.12.2-rc1, build 45bed2c, experimental
ansible --version
ansible 2.1.2.0
ansible-playbook -i inventory play.yml
PLAY [webservers] **************************************************************
TASK [apt] *********************************************************************
changed: [nginxweb]
TASK [service] *****************************************************************
HANGS HERE
At that point if I connect to the container and check Nginx’s status, I can see it being started. If I trigger the service restart service nginx restart then Ansible will finish the play. I am pretty sure it has nothing to do with Ansible since the Docker stable version gives:
Create the container:
docker run -dit --name nginxweb williamyeh/ansible:ubuntu16.04 /bin/bash
Result:
docker --version
Docker version 1.12.1, build 6f9534c
ansible --version
ansible 2.1.2.0
ansible-playbook -i inventory play.yml
PLAY [webservers] **************************************************************
TASK [apt] *********************************************************************
changed: [nginxweb]
TASK [service] *****************************************************************
changed: [nginxweb]
PLAY RECAP *********************************************************************
nginxweb : ok=2 changed=2 unreachable=0 failed=0
Let me know if you need anything else.
Cheers,