prometheus/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 28 Jun 2020 10:32:15 -0500
changeset 52 5a5071d4eaad
parent 8 20975062661d
child 53 9e4f750f5d36
permissions -rw-r--r--
Added grafana role automation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: add grafana apt key
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
  apt_key: url="https://packages.grafana.com/gpg.key"
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
- name: add grafana apt repo
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
  apt_repository: repo="deb https://packages.grafana.com/oss/deb stable main"
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
- name: install prometheus and grafana
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
  become: yes
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    13
  apt: name="{{prometheus_server_apt_packages}}" state="latest"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    15
- name: configure prometheus
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    16
  become: yes
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    17
  template:
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    18
    src: "{{prometheus_server_conf}}"
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    19
    dest: "/etc/prometheus/prometheus.yml"
8
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    20
  notify:
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    21
    - restart prometheus service
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    22
    - restart grafana service
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    23
52
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    24
- name: install grafana prometheus data source
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    25
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    26
  grafana_datasource:
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    27
    name: "Prometheus"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    28
    ds_type: "prometheus"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    29
    ds_url: "http://localhost:9090"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    30
    grafana_url: "http://localhost:3000"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    31
    is_default: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    32
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    33
- name: install grafana plugins
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    34
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    35
  grafana_plugin: name="{{item}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    36
  loop: "{{prometheus_server_grafana_plugins}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    37
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    38
- name: copy dashboards to target
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    39
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    40
  copy:
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    41
    src: "{{prometheus_server_grafana_dashboard_src}}/{{item}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    42
    dest: "/tmp/"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    43
    mode: "0640"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    44
  loop: "{{prometheus_server_grafana_dashboards}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    45
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    46
- name: install grafana dashboards
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    47
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    48
  grafana_dashboard:
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    49
    grafana_url: "http://localhost:3000"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    50
    path: "/tmp/{{item}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    51
  loop: "{{prometheus_server_grafana_dashboards}}"