From f9dcca0d16004f08996d66a045a2e88cdc7f8d1e Mon Sep 17 00:00:00 2001 From: Iain Grant Date: Fri, 10 May 2024 16:53:21 +0100 Subject: [PATCH 1/5] Adds config check before restarting mimir --- roles/mimir/tasks/deploy.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/roles/mimir/tasks/deploy.yml b/roles/mimir/tasks/deploy.yml index 93385c3d..2591d07f 100644 --- a/roles/mimir/tasks/deploy.yml +++ b/roles/mimir/tasks/deploy.yml @@ -67,16 +67,6 @@ group: "mimir" mode: "0755" -- name: Template Mimir config - /etc/mimir/config.yml - ansible.builtin.template: - src: "config.yml.j2" - dest: "/etc/mimir/config.yml" - owner: "mimir" - group: "mimir" - mode: "0644" - notify: - - Restart mimir - - name: Ensure that Mimir rule path exists ansible.builtin.file: path: "{{ mimir_ruler_alert_path }}" @@ -88,12 +78,30 @@ - mimir_ruler_alert_path is defined - mimir_ruler is defined +- name: Template Mimir config - /etc/mimir/config.yml + ansible.builtin.template: + src: "config.yml.j2" + dest: "/etc/mimir/config.yml" + owner: "mimir" + group: "mimir" + mode: "0644" + register: _mimir_config + +- name: Test Mimir config before restarting + ansible.builtin.command: "mimir --config.file=/etc/mimir/config.yml -print.config" + when: _mimir_config.changed + notify: + - Restart mimir + - name: Ensure that Mimir is started ansible.builtin.systemd: name: mimir.service state: started enabled: true +- name: Ensure restart has completed + meta: flush_handlers + - name: Verify that Mimir URL is responding ansible.builtin.uri: url: "http://127.0.0.1:{{ mimir_http_listen_port }}/ready" From 694bcf367fbe67a7430fba9a788ccb23149ec5f2 Mon Sep 17 00:00:00 2001 From: Iain Grant Date: Mon, 13 May 2024 20:56:27 +0100 Subject: [PATCH 2/5] Attempting to implement community constructive :) comments --- roles/mimir/tasks/deploy.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/roles/mimir/tasks/deploy.yml b/roles/mimir/tasks/deploy.yml index 2591d07f..6e133633 100644 --- a/roles/mimir/tasks/deploy.yml +++ b/roles/mimir/tasks/deploy.yml @@ -85,13 +85,11 @@ owner: "mimir" group: "mimir" mode: "0644" - register: _mimir_config + validate: "mimir --config.file=/etc/mimir/config.yml -print.config" + backup: true -- name: Test Mimir config before restarting - ansible.builtin.command: "mimir --config.file=/etc/mimir/config.yml -print.config" - when: _mimir_config.changed - notify: - - Restart mimir +- name: Ensure restart has completed + ansible.builtin.meta: flush_handlers - name: Ensure that Mimir is started ansible.builtin.systemd: @@ -99,8 +97,6 @@ state: started enabled: true -- name: Ensure restart has completed - meta: flush_handlers - name: Verify that Mimir URL is responding ansible.builtin.uri: From 9cb6d4125bc9731e3028f32bb6268890d8970a61 Mon Sep 17 00:00:00 2001 From: Iain Grant Date: Mon, 13 May 2024 22:48:11 +0100 Subject: [PATCH 3/5] Validate attempt 2 --- roles/mimir/tasks/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/mimir/tasks/deploy.yml b/roles/mimir/tasks/deploy.yml index 6e133633..a223ffe1 100644 --- a/roles/mimir/tasks/deploy.yml +++ b/roles/mimir/tasks/deploy.yml @@ -85,8 +85,7 @@ owner: "mimir" group: "mimir" mode: "0644" - validate: "mimir --config.file=/etc/mimir/config.yml -print.config" - backup: true + validate: "mimir --config.file=%s -print.config" - name: Ensure restart has completed ansible.builtin.meta: flush_handlers From eaad837d86dfaa8a9f178d55331b1392cd090f62 Mon Sep 17 00:00:00 2001 From: Iain Grant Date: Mon, 13 May 2024 22:50:07 +0100 Subject: [PATCH 4/5] forgot the restart --- roles/mimir/tasks/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/mimir/tasks/deploy.yml b/roles/mimir/tasks/deploy.yml index a223ffe1..8b40c9a3 100644 --- a/roles/mimir/tasks/deploy.yml +++ b/roles/mimir/tasks/deploy.yml @@ -86,6 +86,8 @@ group: "mimir" mode: "0644" validate: "mimir --config.file=%s -print.config" + notify: + - Restart mimir - name: Ensure restart has completed ansible.builtin.meta: flush_handlers From 27e31e3ea7f6d0883b524533cc3d5f9740e14b65 Mon Sep 17 00:00:00 2001 From: Iain Grant Date: Sat, 18 May 2024 01:14:00 +0100 Subject: [PATCH 5/5] Align the test with the documentation --- roles/mimir/tasks/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mimir/tasks/deploy.yml b/roles/mimir/tasks/deploy.yml index 8b40c9a3..017c5e26 100644 --- a/roles/mimir/tasks/deploy.yml +++ b/roles/mimir/tasks/deploy.yml @@ -85,7 +85,7 @@ owner: "mimir" group: "mimir" mode: "0644" - validate: "mimir --config.file=%s -print.config" + validate: "mimir -modules --config.file=%s" notify: - Restart mimir