monitoring: use config_template module for config

The alertmanager, grafana and prometheus configuration file are
generated with the template module which doesn't allow for using
config overrides.
Instead we could use the config_template plugin action and add a
new variable for overrides (one for each component).

With this patch, one should be able to add configuration to
prometheus with the following:

---
alertmanager_conf_overrides:
  global:
    smtp_smarthost: 'localhost:25'
...

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1902999

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>

(cherry picked from commit 5a41026347)
pull/6749/head
Dimitri Savineau 2020-12-11 13:07:04 -05:00 committed by Guillaume Abrioux
parent 8e939dc377
commit 4695df6d2b
5 changed files with 15 additions and 3 deletions

View File

@ -795,6 +795,7 @@ dummy:
# - grafana-piechart-panel
#grafana_allow_embedding: True
#grafana_port: 3000
#grafana_conf_overrides: {}
#prometheus_container_image: "prom/prometheus:v2.7.2"
#prometheus_container_cpu_period: 100000
#prometheus_container_cpu_cores: 2
@ -817,6 +818,7 @@ dummy:
#alertmanager_conf_dir: /etc/alertmanager
#alertmanager_port: 9093
#alertmanager_cluster_port: 9094
#alertmanager_conf_overrides: {}
# igw
#
# `igw_network` variable is intended for allowing dashboard deployment with iSCSI node not residing in the same subnet than what is defined in `public_network`.

View File

@ -795,6 +795,7 @@ grafana_container_image: registry.redhat.io/rhceph/rhceph-4-dashboard-rhel8:4
# - grafana-piechart-panel
#grafana_allow_embedding: True
#grafana_port: 3000
#grafana_conf_overrides: {}
prometheus_container_image: registry.redhat.io/openshift4/ose-prometheus:v4.6
#prometheus_container_cpu_period: 100000
#prometheus_container_cpu_cores: 2
@ -817,6 +818,7 @@ alertmanager_container_image: registry.redhat.io/openshift4/ose-prometheus-alert
#alertmanager_conf_dir: /etc/alertmanager
#alertmanager_port: 9093
#alertmanager_cluster_port: 9094
#alertmanager_conf_overrides: {}
# igw
#
# `igw_network` variable is intended for allowing dashboard deployment with iSCSI node not residing in the same subnet than what is defined in `public_network`.

View File

@ -787,6 +787,7 @@ grafana_plugins:
- grafana-piechart-panel
grafana_allow_embedding: True
grafana_port: 3000
grafana_conf_overrides: {}
prometheus_container_image: "prom/prometheus:v2.7.2"
prometheus_container_cpu_period: 100000
prometheus_container_cpu_cores: 2
@ -809,6 +810,7 @@ alertmanager_data_dir: /var/lib/alertmanager
alertmanager_conf_dir: /etc/alertmanager
alertmanager_port: 9093
alertmanager_cluster_port: 9094
alertmanager_conf_overrides: {}
# igw
#
# `igw_network` variable is intended for allowing dashboard deployment with iSCSI node not residing in the same subnet than what is defined in `public_network`.

View File

@ -44,12 +44,14 @@
- not ansible_facts['os_family'] in ['RedHat', 'Suse']
- name: write grafana.ini
template:
config_template:
src: grafana.ini.j2
dest: /etc/grafana/grafana.ini
owner: "{{ grafana_uid }}"
group: "{{ grafana_uid }}"
mode: 0640
config_type: ini
config_overrides: "{{ grafana_conf_overrides }}"
- name: write datasources provisioning config file
template:

View File

@ -10,12 +10,14 @@
- "{{ prometheus_data_dir }}"
- name: write prometheus config file
template:
config_template:
src: prometheus.yml.j2
dest: "{{ prometheus_conf_dir }}/prometheus.yml"
owner: "{{ prometheus_user_id }}"
group: "{{ prometheus_user_id }}"
mode: 0640
config_type: yaml
config_overrides: "{{ prometheus_conf_overrides }}"
notify: service handler
- name: make sure the alerting rules directory exists
@ -44,12 +46,14 @@
- "{{ alertmanager_data_dir }}"
- name: write alertmanager config file
template:
config_template:
src: alertmanager.yml.j2
dest: "{{ alertmanager_conf_dir }}/alertmanager.yml"
owner: "{{ prometheus_user_id }}"
group: "{{ prometheus_user_id }}"
mode: 0640
config_type: yaml
config_overrides: "{{ alertmanager_conf_overrides }}"
notify: service handler
- name: include setup_container.yml