From 4695df6d2bb6e5b4ccd93e4b740296ad54a33c75 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 11 Dec 2020 13:07:04 -0500 Subject: [PATCH] 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 (cherry picked from commit 5a410263470932f2f1a22572e0f2c42939591402) --- group_vars/all.yml.sample | 2 ++ group_vars/rhcs.yml.sample | 2 ++ roles/ceph-defaults/defaults/main.yml | 2 ++ roles/ceph-grafana/tasks/configure_grafana.yml | 4 +++- roles/ceph-prometheus/tasks/main.yml | 8 ++++++-- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/group_vars/all.yml.sample b/group_vars/all.yml.sample index eab63c668..e52bae535 100644 --- a/group_vars/all.yml.sample +++ b/group_vars/all.yml.sample @@ -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`. diff --git a/group_vars/rhcs.yml.sample b/group_vars/rhcs.yml.sample index b097952f0..5e8a5af5b 100644 --- a/group_vars/rhcs.yml.sample +++ b/group_vars/rhcs.yml.sample @@ -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`. diff --git a/roles/ceph-defaults/defaults/main.yml b/roles/ceph-defaults/defaults/main.yml index 16bbf2f2e..d26d6cfd4 100644 --- a/roles/ceph-defaults/defaults/main.yml +++ b/roles/ceph-defaults/defaults/main.yml @@ -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`. diff --git a/roles/ceph-grafana/tasks/configure_grafana.yml b/roles/ceph-grafana/tasks/configure_grafana.yml index 57928d321..525b8e6a9 100644 --- a/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/roles/ceph-grafana/tasks/configure_grafana.yml @@ -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: diff --git a/roles/ceph-prometheus/tasks/main.yml b/roles/ceph-prometheus/tasks/main.yml index 50185d306..8987009b7 100644 --- a/roles/ceph-prometheus/tasks/main.yml +++ b/roles/ceph-prometheus/tasks/main.yml @@ -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