The service module seems not to start my docker daemon after explicitly passing the commands. Ansible is not starting up docker daemon in the destination host. Tasks:
- name: Install Docker
apt:
name: docker-engine
state: present
update_cache: yes
- name: Install pip
apt:
name: python-pip
state: present
- name: Install docker-py
pip:
name: docker-py
state: present
- name: Start docker service
service:
name: docker
state: started
enabled: yes
...
That all looks right. Installing docker-engine, confirming the state is present. Installing pip to install docker-py, confirm that it is present. Then ensuring that the docker service is started. However, stderr throws up the following when Trying to create a docker container:
fatal: [ubuntu-xenial]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))"}
...
Issue goes away if log in to the box and start the docker service.
I can work around this issue by implicitly running the command service docker start
using the command
module -- that's how it gets weird... because it works:
- name: Ensure docker service is enabled
command: service docker start
...