From b11c4477d973b0cc87a296f6b028eaf9abab4686 Mon Sep 17 00:00:00 2001 From: haxorof Date: Thu, 25 May 2017 10:58:03 +0200 Subject: [PATCH] Fixes #1 --- .gitignore | 2 +- tasks/main-Generic.yml | 17 +++++++++++++---- tests/files/daemon.json | 3 +++ tests/test_config.yml | 2 +- tests/test_config_file.yml | 8 ++++++++ 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 tests/files/daemon.json create mode 100644 tests/test_config_file.yml diff --git a/.gitignore b/.gitignore index 2ab2193..c5e1064 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .vagrant -.retry +*.retry .vscode/ \ No newline at end of file diff --git a/tasks/main-Generic.yml b/tasks/main-Generic.yml index 1c319c0..2c307c6 100644 --- a/tasks/main-Generic.yml +++ b/tasks/main-Generic.yml @@ -10,7 +10,7 @@ - name: Set fact if old Docker installation shall be removed set_fact: remove_old_docker: "{{docker_remove_pre_ce | bool }} == true and {{ cmd_docker_version.stdout_lines[0] | search('-ce') }} == false" - when: cmd_docker_version.stdout_lines[0] is defined + when: cmd_docker_version.stdout_lines is defined and cmd_docker_version.stdout_lines[0] is defined - name: Check if Docker is running command: systemctl status docker @@ -53,13 +53,22 @@ mode: 0755 become: true -- name: Configure Docker daemon +- name: Configure Docker daemon (file) copy: - content: "{{docker_daemon_config | to_nice_json}}" + src: "{{ docker_daemon_config_file }}" dest: /etc/docker/daemon.json become: true notify: restart docker - when: docker_daemon_config is defined + when: docker_daemon_config_file is defined + +- name: Configure Docker daemon (variables) + copy: + content: "{{ docker_daemon_config | to_nice_json }}" + dest: /etc/docker/daemon.json + become: true + notify: restart docker + when: docker_daemon_config_file is not defined and + docker_daemon_config is defined - name: Enable and start Docker service service: diff --git a/tests/files/daemon.json b/tests/files/daemon.json new file mode 100644 index 0000000..51af6ab --- /dev/null +++ b/tests/files/daemon.json @@ -0,0 +1,3 @@ +{ + "init": true +} \ No newline at end of file diff --git a/tests/test_config.yml b/tests/test_config.yml index ef39b22..9e63174 100644 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -3,6 +3,6 @@ vars: docker_daemon_config: experimental: true - metrics-addr: "{{ ansible_default_ipv4.address }}:9323" + init: true roles: - ansible-role-docker-ce diff --git a/tests/test_config_file.yml b/tests/test_config_file.yml new file mode 100644 index 0000000..1772bbe --- /dev/null +++ b/tests/test_config_file.yml @@ -0,0 +1,8 @@ +--- +- hosts: test-host + vars: + docker_daemon_config_file: "files/daemon.json" + docker_daemon_config: + shall_skip_this: true + roles: + - ansible-role-docker-ce