andrewrothstein / ansible-docker

MIT License
5 stars 8 forks source link

Docker service needs to be restarted in order for storage type be available #8

Open cintiadr opened 7 years ago

cintiadr commented 7 years ago

Hi,

I'm using your role (v 5.0.1) in a ubuntu 16.04 (default vagrant box), following config:

docker_storage_driver: overlay2
docker_remote: False
docker_tls: False

After applying the role, the docker service is still using 'Storage driver: devicemapper' . I have to manually restart the service to get it on overlay2. So the configuration file was modified, but the service doesn't appear to be restarted to pick that change.

The full failing example: https://github.com/cintiadr/test-docker-ansible-role

andrewrothstein commented 7 years ago

this is why Ubuntu/Debian is stinky. when I install a package, please don't start a service on my behalf!

https://major.io/2014/06/26/install-debian-packages-without-starting-daemons/ https://news.ycombinator.com/item?id=7952838

it's really tough to make the role idempotent in the face of this. Can you suggest a fix that doesn't restart the service for each application of the role?

cintiadr commented 7 years ago

Ansible is not really my forte, but as I far as I understand one should either use a handler or a register

http://stackoverflow.com/questions/33931610/ansible-handler-notify-vs-register

Something like: http://docs.ansible.com/ansible/playbooks_intro.html#handlers-running-operations-on-change

But I'm not sure if that's the best way, tbh