1

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
...
Rafael Oliveira
  • 309
  • 2
  • 11
  • It miight not be the root cause at all but... `docker-engine` is a quite old version of docker since the package has long changed name (so maybe *.service name for servicectl too but I'm not sure about that). See the [instructions and methods to install the up-to-date version `docker-ce`](https://docs.docker.com/install/linux/docker-ce/debian/) (I linked to apt debian but ubuntu is there as well). If this does not solve the problem, have you tried to use the `systemctl`, `sysvinit`,... specific modules instead of the agnostic `service` to see if you get the same result ? – Zeitounator Apr 05 '19 at 00:57

1 Answers1

0

I could fix the issue by using sysvinit module, in opposition to service:

- name: Start docker service
  sysvinit:
    name: docker
    state: started
    enabled: yes
Rafael Oliveira
  • 309
  • 2
  • 11