From abd8e3625ef5ae15d13aab6cafbde7c5229f0aa3 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 18 May 2018 16:58:50 -0500 Subject: [PATCH] Fixes #42: Allow control over docker_service state. --- README.md | 6 ++++++ defaults/main.yml | 5 +++++ handlers/main.yml | 2 +- tasks/main.yml | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index abec29f..22ebd15 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml index 0c17481..caa6702 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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" diff --git a/handlers/main.yml b/handlers/main.yml index 43016e0..7847bc1 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,3 @@ --- - name: restart docker - service: name=docker state=restarted + service: "name=docker state={{ docker_restart_handler_state }}" diff --git a/tasks/main.yml b/tasks/main.yml index f47f630..eaf71c5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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