Do not touch docker.json if not option provided

This commit is contained in:
Julien Girardin 2021-02-02 16:30:07 +01:00
parent 0df75aea53
commit 47a271e39a
2 changed files with 10 additions and 7 deletions

View File

@ -28,5 +28,5 @@ 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 as a dict
docker_daemon_options: {}

View File

@ -11,24 +11,27 @@
state: "{{ docker_package_state }}"
notify: restart docker
- name: Ensure Docker is started and enabled at boot.
service:
name: docker
state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}"
- name: Ensure /etc/docker/ directory exists.
file:
path: /etc/docker
state: directory
mode: 0755
when: docker_daemon_options.keys() | length > 0
- name: Configure Docker daemon options.
copy:
content: "{{ docker_daemon_options | to_nice_json }}"
dest: /etc/docker/daemon.json
mode: 0644
when: docker_daemon_options.keys() | length > 0
notify: restart docker
- name: Ensure Docker is started and enabled at boot.
service:
name: docker
state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}"
- name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers