diff --git a/defaults/main.yml b/defaults/main.yml index 51e11ae..4730a34 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: {} diff --git a/tasks/main.yml b/tasks/main.yml index c357ca3..b919fdb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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