diff --git a/prometheus/defaults/main.yml b/prometheus/defaults/main.yml index 150dc1930f02cc796dd6cdd5e0731cbcdc154a09..73de8fb9c25da9001c6f2bd8c7ec41a4d1dc1207 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 ad02add2c9966bac3ebd5b10db6aa546b058c4f1..ce4f8e2c3a41b0b832598f3e9973f243668bd6ee 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 3a5db869d91899b71ebbb9fd6dca511bbaa55cd9..0000000000000000000000000000000000000000 --- 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 ff0d6db9e77c690613f39b9c0c3c61a2708f9432..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..314140f07e0cf301be89ed6351e3a8e54b87c0b3 --- /dev/null +++ b/prometheus/templates/rules.yml.j2 @@ -0,0 +1 @@ +{{ prometheus_rules|to_nice_yaml|replace('[[', '{{')|replace(']]', '}}') }}