From 33afdbb0f828a8bf805e451293d9a540a7bf6361 Mon Sep 17 00:00:00 2001 From: Ricky Kwan Date: Mon, 8 Oct 2018 18:53:22 +0000 Subject: [PATCH] Ability to configure Docker daemon options --- README.md | 7 +++++++ defaults/main.yml | 3 +++ tasks/main.yml | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 9a49840..c34b8de 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,13 @@ Docker Compose installation options. A list of system users to be added to the `docker` group (so they can use Docker on the server). + docker_daemon_options: + storage-driver: "devicemapper" + log-opts: + max-size: "100m" + +Custom `dockerd` options can be configured through this dictionary representing the json file `/etc/docker/daemon.json`. + ## Use with Ansible (and `docker` Python library) Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role: diff --git a/defaults/main.yml b/defaults/main.yml index 2bcb620..51e11ae 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,3 +27,6 @@ docker_yum_repo_enable_test: 0 # A list of users who will be added to the docker group. docker_users: [] + +# Docker daemon options +docker_daemon_options: {} diff --git a/tasks/main.yml b/tasks/main.yml index 8444ac7..1a0de12 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,6 +17,18 @@ state: "{{ docker_service_state }}" enabled: "{{ docker_service_enabled }}" +- name: Ensure /etc/docker/ directory exists. + file: + path: /etc/docker + state: directory + +- name: Configure docker daemon options. + copy: + content: "{{ docker_daemon_options | to_nice_json }}" + dest: /etc/docker/daemon.json + mode: 0644 + notify: restart docker + - name: Ensure handlers are notified now to avoid firewall conflicts. meta: flush_handlers