From eaeb448245a6d267935e7b2d2e1a23c28419fb17 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Fri, 24 Jun 2022 10:29:14 +0200 Subject: [PATCH] Make service management entirely optional The provided advice of circumventing service management did not work for me, usage still failed in WSL: ``` TASK [geerlingguy.docker : Ensure Docker is started and enabled at boot.] ********************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "Service is in unknown state", "status": {}} ``` Thus, this adds the option `docker_service_managed` that allows skipping any service management completely. --- README.md | 3 ++- defaults/main.yml | 1 + tasks/main.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bf9e5f..294526e 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,12 @@ The `docker_edition` should be either `ce` (Community Edition) or `ee` (Enterpri You can control whether the package is installed, uninstalled, or at the latest version by setting `docker_package_state` to `present`, `absent`, or `latest`, respectively. Note that the Docker daemon will be automatically restarted if the Docker package is updated. This is a side effect of flushing all handlers (running any of the handlers that have been notified by this and any other role up to this point in the play). + docker_service_managed: true docker_service_state: started docker_service_enabled: true 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`. +Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a distribution without an init system (e.g. inside a Docker container, WSL), set `docker_service_managed` to `false`. docker_install_compose: true docker_compose_version: "1.26.0" diff --git a/defaults/main.yml b/defaults/main.yml index 9e56e9a..2779893 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,6 +5,7 @@ docker_package: "docker-{{ docker_edition }}" docker_package_state: present # Service options. +docker_service_managed: true docker_service_state: started docker_service_enabled: true docker_restart_handler_state: restarted diff --git a/tasks/main.yml b/tasks/main.yml index 91fceef..57e6aa0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -42,6 +42,7 @@ name: docker state: "{{ docker_service_state }}" enabled: "{{ docker_service_enabled }}" + when: docker_service_managed | bool ignore_errors: "{{ ansible_check_mode }}" - name: Ensure handlers are notified now to avoid firewall conflicts.