Fixes #42: Allow control over docker_service state.

master
Jeff Geerling 2018-05-18 16:58:50 -05:00
parent 2b31b694c0
commit abd8e3625e
4 changed files with 14 additions and 3 deletions

View File

@ -23,6 +23,12 @@ The `docker_edition` should be either `ce` (Community Edition) or `ee` (Enterpri
Whether to restart the Docker daemon after the Docker package is installed or updated. If this is set to `True`, this role will flush all handlers (run any of the handlers that have been notified by this and any other role up to this point in the play). The default setting helps avoid firewall clashes with Docker rules (e.g. when using custom `iptables` rules or the `geerlingguy.firewall` Ansible role).
docker_service_state: started
docker_service_enabled: yes
docker_restart_handler_state: restarted
Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set these to `stopped` and set the enabled variable to `no`.
docker_install_compose: True
docker_compose_version: "1.21.2"
docker_compose_path: /usr/local/bin/docker-compose

View File

@ -5,6 +5,11 @@ docker_package: "docker-{{ docker_edition }}"
docker_package_state: present
docker_restart_on_package_change: True
# Service options.
docker_service_state: started
docker_service_enabled: yes
docker_restart_handler_state: restarted
# Docker Compose options.
docker_install_compose: True
docker_compose_version: "1.21.2"

View File

@ -1,3 +1,3 @@
---
- name: restart docker
service: name=docker state=restarted
service: "name=docker state={{ docker_restart_handler_state }}"

View File

@ -14,8 +14,8 @@
- name: Ensure Docker is started and enabled at boot.
service:
name: docker
state: started
enabled: yes
state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}"
- name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers