Few fixes on systemd unit templates for node_exporter and
alertmanager container parameters.
Added the ability to use a dedicated instance to deploy the
dashboard components (prometheus and grafana).
This commit also introduces the grafana_group_name variable
to refer grafana group and keep consistency with the other
groups.
During the integration with TripleO some grafana/prometheus
template variables resulted undefined. This commit adds the
ability to check if the group exist and create, accordingly,
different job groups in prometheus template.
Signed-off-by: fmount <fpantano@redhat.com>
(cherry picked from commit
069076bbfdef30c64b33dfcdd063b1e31d65d617)
NMDSS = settings['mds_vms']
NRGWS = settings['rgw_vms']
NNFSS = settings['nfs_vms']
+GRAFANA = settings['grafana_server_vms']
NRBD_MIRRORS = settings['rbd_mirror_vms']
CLIENTS = settings['client_vms']
NISCSI_GWS = settings['iscsi_gw_vms']
'nfss' => (0..NNFSS - 1).map { |j| "#{LABEL_PREFIX}nfs#{j}" },
'rbd_mirrors' => (0..NRBD_MIRRORS - 1).map { |j| "#{LABEL_PREFIX}rbd_mirror#{j}" },
'clients' => (0..CLIENTS - 1).map { |j| "#{LABEL_PREFIX}client#{j}" },
- 'iscsigws' => (0..NISCSI_GWS - 1).map { |j| "#{LABEL_PREFIX}iscsi_gw#{j}" },
- 'mgrs' => (0..MGRS - 1).map { |j| "#{LABEL_PREFIX}mgr#{j}" }
+ 'iscsigws' => (0..NISCSI_GWS - 1).map { |j| "#{LABEL_PREFIX}iscsi_gw#{j}" },
+ 'mgrs' => (0..MGRS - 1).map { |j| "#{LABEL_PREFIX}mgr#{j}" },
+ 'grafana-server' => (0..GRAFANA - 1).map { |j| "#{LABEL_PREFIX}grafana#{j}" }
}
ansible.extra_vars = {
end
end
+ (0..GRAFANA - 1).each do |i|
+ config.vm.define "#{LABEL_PREFIX}grafana#{i}" do |grf|
+ grf.vm.hostname = "#{LABEL_PREFIX}grafana#{i}"
+ if ASSIGN_STATIC_IP
+ grf.vm.network :private_network,
+ ip: "#{PUBLIC_SUBNET}.3#{i}"
+ end
+ # Virtualbox
+ grf.vm.provider :virtualbox do |vb|
+ vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
+ end
+
+ # VMware
+ grf.vm.provider :vmware_fusion do |v|
+ v.vmx['memsize'] = "#{MEMORY}"
+ end
+
+ # Libvirt
+ grf.vm.provider :libvirt do |lv|
+ lv.memory = MEMORY
+ lv.random_hostname = true
+ end
+
+ # Parallels
+ grf.vm.provider "parallels" do |prl|
+ prl.name = "ceph-grafana#{i}"
+ prl.memory = "#{MEMORY}"
+ end
+
+ grf.vm.provider :linode do |provider|
+ provider.label = grf.vm.hostname
+ end
+ end
+ end
+
(0..MGRS - 1).each do |i|
config.vm.define "#{LABEL_PREFIX}mgr#{i}" do |mgr|
mgr.vm.hostname = "#{LABEL_PREFIX}mgr#{i}"
#iscsi_gw_group_name: iscsigws
#mgr_group_name: mgrs
#rgwloadbalancer_group_name: rgwloadbalancers
+#grafana_server_group_name: grafana-server
# If configure_firewall is true, then ansible will try to configure the
# appropriate firewalling rules so that Ceph daemons can communicate
#dashboard_rgw_api_scheme: ''
#dashboard_rgw_api_admin_resource: ''
#dashboard_rgw_api_no_ssl_verify: False
-
+#grafana_server_group_name: grafana-server
#iscsi_gw_group_name: iscsigws
#mgr_group_name: mgrs
#rgwloadbalancer_group_name: rgwloadbalancers
+#grafana_server_group_name: grafana-server
# If configure_firewall is true, then ansible will try to configure the
# appropriate firewalling rules so that Ceph daemons can communicate
delegate_to: "{{ groups[mon_group_name][0] }}"
until: ac_result.rc == 0
+- name: set grafana url to grafana instance
+ set_fact:
+ dashboard_url: "{{ groups[grafana_server_group_name][0] }}"
+ when: "{{ groups.grafana_server_group_name is defined and groups[grafana_server_group_name] | length > 0 }}"
+
+- name: set grafana url to mon
+ set_fact:
+ dashboard_url: "{{ groups[mon_group_name][0] }}"
+ when: "{{ groups.grafana_server_group_name is not defined or groups[grafana_server_group_name] | length == 0 }}"
+
- name: set grafana url
- command: "{{ container_exec_cmd }} ceph dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ groups['grafana-server'][0] }}:3000/"
+ command: "{{ container_exec_cmd }} ceph dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ dashboard_url }}:3000/"
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: false
- name: set alertmanager host
- command: "{{ container_exec_cmd }} ceph dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ groups['grafana-server'][0] }}:9093/"
+ command: "{{ container_exec_cmd }} ceph dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ dashboard_url }}:9093/"
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: false
iscsi_gw_group_name: iscsigws
mgr_group_name: mgrs
rgwloadbalancer_group_name: rgwloadbalancers
+grafana_server_group_name: grafana-server
# If configure_firewall is true, then ansible will try to configure the
# appropriate firewalling rules so that Ceph daemons can communicate
set_fact:
ntp_service_name: ntpd
when: ansible_os_family in ['RedHat', 'Suse']
+
+- name: set grafana_server_addr fact
+ set_fact:
+ grafana_server_addr: "{{ (hostvars[groups[grafana_server_group_name][0] | default(groups[mgr_group_name][0])])['ansible_all_ipv4_addresses'] | ipaddr(public_network) | first }}"
+ when: groups.get(grafana_server_group_name, []) | length > 0 or groups.get(mgr_group_name, []) | length > 0
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string> url
- url: 'http://{{ groups["grafana-server"][0] }}:9090'
+ url: 'http://{{ grafana_server_addr | default(_current_monitor_address) }}:9090'
# <bool> enable/disable basic auth
basicAuth: false
# <bool> mark as default datasource. Max one per org
ExecStart=/usr/bin/{{ container_binary }} run --name=node-exporter \
-v /proc:/host/proc:ro -v /sys:/host/sys:ro \
--net=host \
+ {{ node_exporter_container_image }}
--path.procfs=/host/proc \
--path.sysfs=/host/sys \
--no-collector.timex \
- {{ node_exporter_container_image }}
# 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
{% endif %}
[Service]
+WorkingDirectory={{ alertmanager_data_dir }}
EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager
ExecStart=/usr/bin/{{ container_binary }} run --name=alertmanager \
{% endfor %}
- job_name: 'node'
static_configs:
-{% for host in (groups['all'] | difference(groups['grafana-server'])) %}
+{% if grafana_server_group_name in groups %}
+{% for host in (groups['all'] | difference(groups[grafana_server_group_name])) %}
- targets: ['{{ host }}:9100']
labels:
instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
- job_name: 'grafana'
static_configs:
-{% for host in groups['grafana-server'] %}
+{% for host in groups[grafana_server_group_name] %}
- targets: ['{{ host }}:9100']
labels:
instance: "{{ hostvars[host]['ansible_nodename'] }}"
{% endfor %}
+{% else %}
+{% for host in groups['all'] %}
+ - targets: ['{{ host }}:9100']
+ labels:
+ instance: "{{ hostvars[host]['ansible_nodename'] }}"
+{% endfor %}
+{% endif %}
{% if 'iscsigws' in groups %}
- job_name: 'iscsi-gws'
static_configs:
alertmanagers:
- scheme: http
static_configs:
- - targets: ['{{ groups["grafana-server"][0] }}:9093']
+ - targets: ['{{ grafana_server_addr | default(_current_monitor_address) }}:9093']
run_once: true
when: not ceph_status.failed
-- hosts: grafana-server
+- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}'
become: true
tasks:
- block:
name: ceph-grafana
when: dashboard_enabled | bool
-- hosts: '{{ (groups["mgrs"] | default(groups["mons"]))[0] }}'
+- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}'
become: true
tasks:
- block:
name: ceph-node-exporter
when: dashboard_enabled | bool
-
-- hosts: grafana-server
+- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}'
become: true
tasks:
- block:
name: ceph-grafana
when: dashboard_enabled | bool
-- hosts: '{{ (groups["mgrs"] | default(groups["mons"]))[0] }}'
+- hosts: '{{ groups["grafana-server"][0] | default(groups["mgrs"][0]) | default(groups["mons"][0]) | default(omit) }}'
become: true
tasks:
- import_role:
mds_vms: 1
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 1
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 1
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 1
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 1
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 1
client_vms: 2
iscsi_gw_vms: 1
mds_vms: 1
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 1
client_vms: 2
iscsi_gw_vms: 1
mds_vms: 1
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 1
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 1
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 3
iscsi_gw_vms: 0
mds_vms: 1
rgw_vms: 1
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 1
client_vms: 2
iscsi_gw_vms: 1
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0
mds_vms: 0
rgw_vms: 0
nfs_vms: 0
+grafana_server_vms: 0
rbd_mirror_vms: 0
client_vms: 0
iscsi_gw_vms: 0