From: Guillaume Abrioux Date: Mon, 13 May 2019 14:21:16 +0000 (+0200) Subject: dashboard: rename template files X-Git-Tag: v4.0.0rc8~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=997d179b7cc1ebbc95acca6bda41ed40afa9f130;p=ceph-ansible.git dashboard: rename template files add .j2 to all templates file related to dashboard roles. Signed-off-by: Guillaume Abrioux (cherry picked from commit 3578d576a4c16b9be68c403addf07d3c30c67117) --- diff --git a/roles/ceph-grafana/tasks/configure_grafana.yml b/roles/ceph-grafana/tasks/configure_grafana.yml index e031e171a..80522e42f 100644 --- a/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/roles/ceph-grafana/tasks/configure_grafana.yml @@ -20,19 +20,19 @@ - name: write grafana.ini template: - src: grafana.ini + src: grafana.ini.j2 dest: /etc/grafana/grafana.ini mode: 0640 - name: write datasources provisioning config file template: - src: datasources-ceph-dashboard.yml + src: datasources-ceph-dashboard.yml.j2 dest: /etc/grafana/provisioning/datasources/ceph-dashboard.yml mode: 0640 - name: Write dashboards provisioning config file template: - src: dashboards-ceph-dashboard.yml + src: dashboards-ceph-dashboard.yml.j2 dest: /etc/grafana/provisioning/dashboards/ceph-dashboard.yml mode: 0640 diff --git a/roles/ceph-grafana/tasks/setup_container.yml b/roles/ceph-grafana/tasks/setup_container.yml index 3bb8dfcc2..7889d7194 100644 --- a/roles/ceph-grafana/tasks/setup_container.yml +++ b/roles/ceph-grafana/tasks/setup_container.yml @@ -48,8 +48,8 @@ - name: ship systemd service template: - src: grafana-server.service - dest: "/etc/systemd/system/" + src: grafana-server.service.j2 + dest: "/etc/systemd/system/grafana-server.service" owner: root group: root mode: 0644 diff --git a/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml b/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml deleted file mode 100644 index 64dbf1d1a..000000000 --- a/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: 1 - -providers: -- name: 'Ceph Dashboard' - orgId: 1 - folder: 'ceph-dashboard' - type: file - disableDeletion: false - updateIntervalSeconds: 3 - editable: false - options: - path: '{{ grafana_dashboards_path }}' diff --git a/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml.j2 b/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml.j2 new file mode 100644 index 000000000..64dbf1d1a --- /dev/null +++ b/roles/ceph-grafana/templates/dashboards-ceph-dashboard.yml.j2 @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: +- name: 'Ceph Dashboard' + orgId: 1 + folder: 'ceph-dashboard' + type: file + disableDeletion: false + updateIntervalSeconds: 3 + editable: false + options: + path: '{{ grafana_dashboards_path }}' diff --git a/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml b/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml deleted file mode 100644 index 5d5ab0125..000000000 --- a/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: 1 - -# list of datasources that should be deleted from the database -deleteDatasources: - - name: '{{ grafana_datasource }}' - orgId: 1 - -# list of datasources to insert/update depending -# what's available in the database -datasources: - # name of the datasource. Required -- name: '{{ grafana_datasource }}' - # datasource type. Required - type: 'prometheus' - # access mode. proxy or direct (Server or Browser in the UI). Required - access: 'proxy' - # org id. will default to orgId 1 if not specified - orgId: 1 - # url - url: 'http://{{ groups["grafana-server"][0] }}:9090' - # enable/disable basic auth - basicAuth: false - # mark as default datasource. Max one per org - isDefault: true - # allow users to edit datasources from the UI. - editable: false diff --git a/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 b/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 new file mode 100644 index 000000000..5d5ab0125 --- /dev/null +++ b/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 @@ -0,0 +1,26 @@ +apiVersion: 1 + +# list of datasources that should be deleted from the database +deleteDatasources: + - name: '{{ grafana_datasource }}' + orgId: 1 + +# list of datasources to insert/update depending +# what's available in the database +datasources: + # name of the datasource. Required +- name: '{{ grafana_datasource }}' + # datasource type. Required + type: 'prometheus' + # access mode. proxy or direct (Server or Browser in the UI). Required + access: 'proxy' + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: 'http://{{ groups["grafana-server"][0] }}:9090' + # enable/disable basic auth + basicAuth: false + # mark as default datasource. Max one per org + isDefault: true + # allow users to edit datasources from the UI. + editable: false diff --git a/roles/ceph-grafana/templates/grafana-server.service b/roles/ceph-grafana/templates/grafana-server.service deleted file mode 100644 index b242a18f8..000000000 --- a/roles/ceph-grafana/templates/grafana-server.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is managed by ansible, don't make changes here - they will be -# overwritten. -[Unit] -Description=grafana-server -{% if container_binary == 'docker' %} -After=docker.service -{% endif %} - -[Service] -EnvironmentFile=-/etc/environment -ExecStart=/usr/bin/{{ container_binary }} start --attach grafana-server -ExecStop=-/usr/bin/{{ container_binary }} stop grafana-server -Restart=always -RestartSec=10s -TimeoutStartSec=120 -TimeoutStopSec=15 - -[Install] -WantedBy=multi-user.target diff --git a/roles/ceph-grafana/templates/grafana-server.service.j2 b/roles/ceph-grafana/templates/grafana-server.service.j2 new file mode 100644 index 000000000..dd647495d --- /dev/null +++ b/roles/ceph-grafana/templates/grafana-server.service.j2 @@ -0,0 +1,19 @@ +# This file is managed by ansible, don't make changes here - they will be +# overwritten. +[Unit] +Description=grafana-server +{% if container_binary == 'docker' %} +After=docker.service +{% endif %} + + [Service] +EnvironmentFile=-/etc/environment +ExecStart=/usr/bin/{{ container_binary }} start --attach grafana-server +ExecStop=-/usr/bin/{{ container_binary }} stop grafana-server +Restart=always +RestartSec=10s +TimeoutStartSec=120 +TimeoutStopSec=15 + + [Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/ceph-grafana/templates/grafana.ini b/roles/ceph-grafana/templates/grafana.ini deleted file mode 100644 index 0ea67e9fa..000000000 --- a/roles/ceph-grafana/templates/grafana.ini +++ /dev/null @@ -1,26 +0,0 @@ -# [server] -# root_url = %(protocol)s://%(domain)s:%(http_port)s/api/grafana/proxy - -[users] -default_theme = light - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -enabled = true - -# specify organization name that should be used for unauthenticated users -org_name = Main Org. - -# specify role for unauthenticated users -org_role = Viewer - -[server] -cert_file = /etc/grafana/ceph-dashboard.crt -cert_key = /etc/grafana/ceph-dashboard.key -domain = {{ ansible_fqdn }} -protocol = {{ dashboard_protocol }} - -[security] -admin_user = {{ grafana_admin_user }} -admin_password = {{ grafana_admin_password }} diff --git a/roles/ceph-grafana/templates/grafana.ini.j2 b/roles/ceph-grafana/templates/grafana.ini.j2 new file mode 100644 index 000000000..0ea67e9fa --- /dev/null +++ b/roles/ceph-grafana/templates/grafana.ini.j2 @@ -0,0 +1,26 @@ +# [server] +# root_url = %(protocol)s://%(domain)s:%(http_port)s/api/grafana/proxy + +[users] +default_theme = light + +#################################### Anonymous Auth ########################## +[auth.anonymous] +# enable anonymous access +enabled = true + +# specify organization name that should be used for unauthenticated users +org_name = Main Org. + +# specify role for unauthenticated users +org_role = Viewer + +[server] +cert_file = /etc/grafana/ceph-dashboard.crt +cert_key = /etc/grafana/ceph-dashboard.key +domain = {{ ansible_fqdn }} +protocol = {{ dashboard_protocol }} + +[security] +admin_user = {{ grafana_admin_user }} +admin_password = {{ grafana_admin_password }} diff --git a/roles/ceph-node-exporter/tasks/setup_container.yml b/roles/ceph-node-exporter/tasks/setup_container.yml index a72e5c20c..6a557f23c 100644 --- a/roles/ceph-node-exporter/tasks/setup_container.yml +++ b/roles/ceph-node-exporter/tasks/setup_container.yml @@ -29,8 +29,8 @@ - name: ship systemd service template: - src: node_exporter.service - dest: "/etc/systemd/system/" + src: node_exporter.service.j2 + dest: "/etc/systemd/system/node_exporter.service" owner: root group: root mode: 0644 diff --git a/roles/ceph-node-exporter/templates/node_exporter.service b/roles/ceph-node-exporter/templates/node_exporter.service deleted file mode 100644 index 489ba7275..000000000 --- a/roles/ceph-node-exporter/templates/node_exporter.service +++ /dev/null @@ -1,22 +0,0 @@ -# This file is managed by ansible, don't make changes here - they will be -# overwritten. -[Unit] -Description=Node Exporter -{% if container_binary == 'docker' %} -After=docker.service -{% endif %} - -[Service] -EnvironmentFile=-/etc/environment -ExecStart=/usr/bin/{{ container_binary }} start --attach node-exporter -# Make sure the cfg80211 is loaded before running the container, the node -# exporter needs this module loaded to test for presence of wi-fi devices -ExecStartPre=/usr/sbin/modprobe cfg80211 -ExecStop=-/usr/bin/{{ container_binary }} stop node-exporter -Restart=always -RestartSec=10s -TimeoutStartSec=120 -TimeoutStopSec=15 - -[Install] -WantedBy=multi-user.target diff --git a/roles/ceph-node-exporter/templates/node_exporter.service.j2 b/roles/ceph-node-exporter/templates/node_exporter.service.j2 new file mode 100644 index 000000000..489ba7275 --- /dev/null +++ b/roles/ceph-node-exporter/templates/node_exporter.service.j2 @@ -0,0 +1,22 @@ +# This file is managed by ansible, don't make changes here - they will be +# overwritten. +[Unit] +Description=Node Exporter +{% if container_binary == 'docker' %} +After=docker.service +{% endif %} + +[Service] +EnvironmentFile=-/etc/environment +ExecStart=/usr/bin/{{ container_binary }} start --attach node-exporter +# Make sure the cfg80211 is loaded before running the container, the node +# exporter needs this module loaded to test for presence of wi-fi devices +ExecStartPre=/usr/sbin/modprobe cfg80211 +ExecStop=-/usr/bin/{{ container_binary }} stop node-exporter +Restart=always +RestartSec=10s +TimeoutStartSec=120 +TimeoutStopSec=15 + +[Install] +WantedBy=multi-user.target diff --git a/roles/ceph-prometheus/tasks/main.yml b/roles/ceph-prometheus/tasks/main.yml index 39f15008e..71affd66b 100644 --- a/roles/ceph-prometheus/tasks/main.yml +++ b/roles/ceph-prometheus/tasks/main.yml @@ -10,7 +10,7 @@ - name: write prometheus config file template: - src: prometheus.yml + src: prometheus.yml.j2 dest: "{{ prometheus_conf_dir }}/" owner: "{{ prometheus_user_id }}" notify: service handler @@ -40,7 +40,7 @@ - name: write alertmanager config file template: - src: alertmanager.yml + src: alertmanager.yml.j2 dest: "{{ alertmanager_conf_dir }}/" owner: "root" notify: service handler diff --git a/roles/ceph-prometheus/tasks/setup_container.yml b/roles/ceph-prometheus/tasks/setup_container.yml index fddbed7d4..b78134cf3 100644 --- a/roles/ceph-prometheus/tasks/setup_container.yml +++ b/roles/ceph-prometheus/tasks/setup_container.yml @@ -62,8 +62,8 @@ - name: ship systemd services template: - src: "{{ item }}" - dest: "/etc/systemd/system/" + src: "{{ item }}.j2" + dest: "/etc/systemd/system/{{ item }}" owner: root group: root mode: 0644 diff --git a/roles/ceph-prometheus/templates/alertmanager.service b/roles/ceph-prometheus/templates/alertmanager.service deleted file mode 100644 index 80eb573f3..000000000 --- a/roles/ceph-prometheus/templates/alertmanager.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is managed by ansible, don't make changes here - they will be -# overwritten. -[Unit] -Description=alertmanager -{% if container_binary == 'docker' %} -After=docker.service -{% endif %} - -[Service] -EnvironmentFile=-/etc/environment -ExecStart=/usr/bin/{{ container_binary }} start --attach alertmanager -ExecStop=/usr/bin/{{ container_binary }} stop alertmanager -Restart=always -RestartSec=10s -TimeoutStartSec=120 -TimeoutStopSec=15 - -[Install] -WantedBy=multi-user.target diff --git a/roles/ceph-prometheus/templates/alertmanager.service.j2 b/roles/ceph-prometheus/templates/alertmanager.service.j2 new file mode 100644 index 000000000..80eb573f3 --- /dev/null +++ b/roles/ceph-prometheus/templates/alertmanager.service.j2 @@ -0,0 +1,19 @@ +# This file is managed by ansible, don't make changes here - they will be +# overwritten. +[Unit] +Description=alertmanager +{% if container_binary == 'docker' %} +After=docker.service +{% endif %} + +[Service] +EnvironmentFile=-/etc/environment +ExecStart=/usr/bin/{{ container_binary }} start --attach alertmanager +ExecStop=/usr/bin/{{ container_binary }} stop alertmanager +Restart=always +RestartSec=10s +TimeoutStartSec=120 +TimeoutStopSec=15 + +[Install] +WantedBy=multi-user.target diff --git a/roles/ceph-prometheus/templates/alertmanager.yml b/roles/ceph-prometheus/templates/alertmanager.yml deleted file mode 100644 index 4408de0aa..000000000 --- a/roles/ceph-prometheus/templates/alertmanager.yml +++ /dev/null @@ -1,15 +0,0 @@ -global: - resolve_timeout: 5m - -route: - group_by: ['alertname'] - group_wait: 10s - group_interval: 10s - repeat_interval: 1h - receiver: 'ceph-dashboard' -receivers: -- name: 'ceph-dashboard' - webhook_configs: -{% for host in groups['mgrs'] | default(groups['mons']) %} - - url: '{{ dashboard_protocol }}://{{ host }}:{{ dashboard_port }}/api/prometheus_receiver' -{% endfor %} diff --git a/roles/ceph-prometheus/templates/alertmanager.yml.j2 b/roles/ceph-prometheus/templates/alertmanager.yml.j2 new file mode 100644 index 000000000..4408de0aa --- /dev/null +++ b/roles/ceph-prometheus/templates/alertmanager.yml.j2 @@ -0,0 +1,15 @@ +global: + resolve_timeout: 5m + +route: + group_by: ['alertname'] + group_wait: 10s + group_interval: 10s + repeat_interval: 1h + receiver: 'ceph-dashboard' +receivers: +- name: 'ceph-dashboard' + webhook_configs: +{% for host in groups['mgrs'] | default(groups['mons']) %} + - url: '{{ dashboard_protocol }}://{{ host }}:{{ dashboard_port }}/api/prometheus_receiver' +{% endfor %} diff --git a/roles/ceph-prometheus/templates/prometheus.service b/roles/ceph-prometheus/templates/prometheus.service deleted file mode 100644 index 6971eadfc..000000000 --- a/roles/ceph-prometheus/templates/prometheus.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is managed by ansible, don't make changes here - they will be -# overwritten. -[Unit] -Description=prometheus -{% if container_binary == 'docker' %} -After=docker.service -{% endif %} - -[Service] -EnvironmentFile=-/etc/environment -ExecStart=/usr/bin/{{ container_binary }} start --attach prometheus -ExecStop=/usr/bin/{{ container_binary }} stop prometheus -Restart=always -RestartSec=10s -TimeoutStartSec=120 -TimeoutStopSec=15 - -[Install] -WantedBy=multi-user.target diff --git a/roles/ceph-prometheus/templates/prometheus.service.j2 b/roles/ceph-prometheus/templates/prometheus.service.j2 new file mode 100644 index 000000000..6971eadfc --- /dev/null +++ b/roles/ceph-prometheus/templates/prometheus.service.j2 @@ -0,0 +1,19 @@ +# This file is managed by ansible, don't make changes here - they will be +# overwritten. +[Unit] +Description=prometheus +{% if container_binary == 'docker' %} +After=docker.service +{% endif %} + +[Service] +EnvironmentFile=-/etc/environment +ExecStart=/usr/bin/{{ container_binary }} start --attach prometheus +ExecStop=/usr/bin/{{ container_binary }} stop prometheus +Restart=always +RestartSec=10s +TimeoutStartSec=120 +TimeoutStopSec=15 + +[Install] +WantedBy=multi-user.target diff --git a/roles/ceph-prometheus/templates/prometheus.yml b/roles/ceph-prometheus/templates/prometheus.yml deleted file mode 100644 index 71dcbb6a1..000000000 --- a/roles/ceph-prometheus/templates/prometheus.yml +++ /dev/null @@ -1,47 +0,0 @@ -global: - scrape_interval: 15s - evaluation_interval: 15s - -rule_files: - - '/etc/prometheus/alerting/*' - -scrape_configs: - - job_name: 'prometheus' - static_configs: - - targets: ['localhost:9090'] - - job_name: 'ceph' - honor_labels: true - static_configs: -{% for host in groups['mgrs'] | default(groups['mons']) %} - - targets: ['{{ host }}:9283'] - labels: - instance: 'ceph_cluster' -{% endfor %} - - job_name: 'node' - static_configs: -{% for host in (groups['all'] | difference(groups['grafana-server'])) %} - - targets: ['{{ host }}:9100'] - labels: - instance: "{{ hostvars[host]['ansible_nodename'] }}" -{% endfor %} - - job_name: 'grafana' - static_configs: -{% for host in groups['grafana-server'] %} - - targets: ['{{ host }}:9100'] - labels: - instance: "{{ hostvars[host]['ansible_nodename'] }}" -{% endfor %} -{% if 'iscsigws' in groups %} - - job_name: 'iscsi-gws' - static_configs: -{% for host in groups['iscsigws'] %} - - targets: ['{{ host }}:9287'] - labels: - instance: "{{ hostvars[host]['ansible_nodename'] }}" -{% endfor %} -{% endif %} -alerting: - alertmanagers: - - scheme: http - static_configs: - - targets: ['{{ groups["grafana-server"][0] }}:9093'] diff --git a/roles/ceph-prometheus/templates/prometheus.yml.j2 b/roles/ceph-prometheus/templates/prometheus.yml.j2 new file mode 100644 index 000000000..71dcbb6a1 --- /dev/null +++ b/roles/ceph-prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,47 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +rule_files: + - '/etc/prometheus/alerting/*' + +scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + - job_name: 'ceph' + honor_labels: true + static_configs: +{% for host in groups['mgrs'] | default(groups['mons']) %} + - targets: ['{{ host }}:9283'] + labels: + instance: 'ceph_cluster' +{% endfor %} + - job_name: 'node' + static_configs: +{% for host in (groups['all'] | difference(groups['grafana-server'])) %} + - targets: ['{{ host }}:9100'] + labels: + instance: "{{ hostvars[host]['ansible_nodename'] }}" +{% endfor %} + - job_name: 'grafana' + static_configs: +{% for host in groups['grafana-server'] %} + - targets: ['{{ host }}:9100'] + labels: + instance: "{{ hostvars[host]['ansible_nodename'] }}" +{% endfor %} +{% if 'iscsigws' in groups %} + - job_name: 'iscsi-gws' + static_configs: +{% for host in groups['iscsigws'] %} + - targets: ['{{ host }}:9287'] + labels: + instance: "{{ hostvars[host]['ansible_nodename'] }}" +{% endfor %} +{% endif %} +alerting: + alertmanagers: + - scheme: http + static_configs: + - targets: ['{{ groups["grafana-server"][0] }}:9093']