From b5f028f7ed2293e164f48cc2f1c11c1939a5a129 Mon Sep 17 00:00:00 2001 From: Sam Al-Sapti Date: Wed, 28 Dec 2022 17:55:35 +0100 Subject: [PATCH] Move all Docker tasks under services tag --- roles/docker/tasks/docker.yml | 23 ----------------------- roles/docker/tasks/main.yml | 5 +++-- roles/docker/tasks/services.yml | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 25 deletions(-) delete mode 100644 roles/docker/tasks/docker.yml diff --git a/roles/docker/tasks/docker.yml b/roles/docker/tasks/docker.yml deleted file mode 100644 index 3d54497..0000000 --- a/roles/docker/tasks/docker.yml +++ /dev/null @@ -1,23 +0,0 @@ -# vim: ft=yaml.ansible ---- -- name: Copy Docker daemon config file - template: - src: daemon.json.j2 - dest: /etc/docker/daemon.json - owner: root - mode: u=rw,g=r,o=r - register: daemon_config - -- name: Disable and (re)start Docker daemon - service: - name: "{{ item }}" - enabled: false - state: "{{ 'restarted' if daemon_config.changed else 'started' }}" - loop: - - docker.socket - - docker.service - -- name: Set up Docker services - import_tasks: services.yml - tags: - - services diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 3d6bdfc..b43f2ce 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -37,7 +37,8 @@ - docker - docker-compose -- name: Set up Docker - import_tasks: docker.yml +- name: Set up Docker services + import_tasks: services.yml tags: + - services - reboot diff --git a/roles/docker/tasks/services.yml b/roles/docker/tasks/services.yml index c0f5a22..09d9a36 100644 --- a/roles/docker/tasks/services.yml +++ b/roles/docker/tasks/services.yml @@ -1,5 +1,22 @@ # vim: ft=yaml.ansible --- +- name: Copy Docker daemon config file + template: + src: daemon.json.j2 + dest: /etc/docker/daemon.json + owner: root + mode: u=rw,g=r,o=r + register: daemon_config + +- name: Disable and (re)start Docker daemon + service: + name: "{{ item }}" + enabled: false + state: "{{ 'restarted' if daemon_config.changed else 'started' }}" + loop: + - docker.socket + - docker.service + - name: Create base directory for Docker volumes file: name: "{{ base_volume }}"