From 7465ced7bec79fffe06160daa8ade8206840a1d6 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <tschneider@asta.rwth-aachen.de> Date: Fri, 20 Mar 2020 21:55:01 +0100 Subject: [PATCH] Merge rules variables and files --- prometheus/defaults/main.yml | 10 +++------- prometheus/tasks/main.yml | 7 ++----- prometheus/templates/alert_rules.yml.j2 | 1 - prometheus/templates/recording_rules.yml.j2 | 1 - prometheus/templates/rules.yml.j2 | 1 + 5 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 prometheus/templates/alert_rules.yml.j2 delete mode 100644 prometheus/templates/recording_rules.yml.j2 create mode 100644 prometheus/templates/rules.yml.j2 diff --git a/prometheus/defaults/main.yml b/prometheus/defaults/main.yml index 150dc19..73de8fb 100644 --- a/prometheus/defaults/main.yml +++ b/prometheus/defaults/main.yml @@ -1,9 +1,5 @@ --- prometheus_args: "" -prometheus: - rules: - # These variables intentionally left null. They need to exist, so that the - # template works, but they need to have a value (empty string does not - # work). - alert: null - recording: null +# This variable intentionally left null. They need to exist, so that the +# template works, but they need to have a value (empty string does not work). +prometheus_rules: null diff --git a/prometheus/tasks/main.yml b/prometheus/tasks/main.yml index ad02add..ce4f8e2 100644 --- a/prometheus/tasks/main.yml +++ b/prometheus/tasks/main.yml @@ -43,12 +43,9 @@ - name: Configure rules template: - src: "{{ item }}_rules.yml.j2" - dest: "/etc/prometheus/rules/ansible_{{ item }}.yml" + src: "rules.yml.j2" + dest: "/etc/prometheus/rules/ansible_rules.yml" validate: "promtool check rules %s" - with_items: - - alert - - recording notify: - Reload prometheus tags: diff --git a/prometheus/templates/alert_rules.yml.j2 b/prometheus/templates/alert_rules.yml.j2 deleted file mode 100644 index 3a5db86..0000000 --- a/prometheus/templates/alert_rules.yml.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ prometheus.rules.alert|to_nice_yaml }} diff --git a/prometheus/templates/recording_rules.yml.j2 b/prometheus/templates/recording_rules.yml.j2 deleted file mode 100644 index ff0d6db..0000000 --- a/prometheus/templates/recording_rules.yml.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ prometheus.rules.recording|to_nice_yaml }} diff --git a/prometheus/templates/rules.yml.j2 b/prometheus/templates/rules.yml.j2 new file mode 100644 index 0000000..314140f --- /dev/null +++ b/prometheus/templates/rules.yml.j2 @@ -0,0 +1 @@ +{{ prometheus_rules|to_nice_yaml|replace('[[', '{{')|replace(']]', '}}') }} -- GitLab