Add the possibility to customize the options in '/etc/docker/daemon.json'.

This commit is contained in:
Mihai Vultur 2020-03-18 18:16:29 +00:00
parent cd50bf980b
commit ffb63b65e3
4 changed files with 27 additions and 0 deletions

View File

@ -19,6 +19,16 @@ Available variables are listed below, along with default values (see `defaults/m
The `docker_edition` should be either `ce` (Community Edition) or `ee` (Enterprise Edition). You can also specify a specific version of Docker to install using the distribution-specific format: Red Hat/CentOS: `docker-{{ docker_edition }}-<VERSION>`; Debian/Ubuntu: `docker-{{ docker_edition }}=<VERSION>`.
You can customize `daemon configuration` by providing `daemon.json` values in yaml format. Example:
docker_config_options:
exec-opts:
- native.cgroupdriver=systemd
log-driver: journald
max-concurrent-downloads: 7
max-concurrent-uploads: 5
storage-driver: overlay2
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_state: started

View File

@ -9,6 +9,11 @@ docker_service_state: started
docker_service_enabled: true
docker_restart_handler_state: restarted
# Docker config options.
docker_config_options:
max-concurrent-downloads: 5
max-concurrent-uploads: 5
# Docker Compose options.
docker_install_compose: true
docker_compose_version: "1.25.4"

View File

@ -11,6 +11,17 @@
state: "{{ docker_package_state }}"
notify: restart docker
- name: Ensure /etc/docker exists
file:
path: /etc/docker
state: directory
- name: Install daemon.json
template:
src: docker-daemon.json.j2
dest: /etc/docker/daemon.json
notify: restart docker
- name: Ensure Docker is started and enabled at boot.
service:
name: docker

View File

@ -0,0 +1 @@
{{ docker_config_options | default([])| to_nice_json }}