Skip to content

Commit

Permalink
Check that docker daemon is running before continuing with install/ch…
Browse files Browse the repository at this point in the history
…anges (#39)

* #38 - Prevent potential unnecessary service restarts by sorting daemon.json by keys to ensure a net-zero changes to the config don\t cause diffs.

* #38 - Check that docker daemon is running any time the service is potentially started/restarted.
  • Loading branch information
micahkemp-splunk authored Feb 26, 2021
1 parent 11b1926 commit 0438a4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions roles/docker_node/tasks/docker-daemon-running.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# before moving on, make sure the docker daemon is actually up, by asking it for a list of images
- name: ask docker for a list of images
docker_image_info: {}
become: "{{ true if docker_become_user is defined else false }}"
become_user: "{{ docker_become_user }}"
# try every 10 seconds for a minute to see if the service comes up
delay: 10
retries: 6
register: docker_image_info_result
until: docker_image_info_result is not failed
6 changes: 6 additions & 0 deletions roles/docker_node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# also restart the service if any chnages to the packages were made
- include_tasks: docker-enable-start-restart.yml

- name: make sure docker is running
include_tasks: docker-daemon-running.yml

- name: install /etc/docker/daemon.json
template:
src: daemon.json
Expand All @@ -32,3 +35,6 @@
vars:
docker_service_state: restarted
when: docker_daemon_json_result.changed

- name: make sure docker is running
include_tasks: docker-daemon-running.yml
2 changes: 1 addition & 1 deletion roles/docker_node/templates/daemon.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ docker_daemon_config | to_nice_json(indent=2) }}
{{ docker_daemon_config | to_nice_json(indent=2, sort_keys=True) }}

0 comments on commit 0438a4e

Please sign in to comment.