prometheus/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 05 Sep 2022 17:58:32 -0500
changeset 188 4f2ad619134b
parent 187 0f3a64c60ec5
child 189 3bd85e235e76
permissions -rw-r--r--
Added apt-cacher handler.
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
187
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    15
- name: make prometheus data dir
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    16
  become: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    17
  file:
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    18
    path: "{{prometheus_server_data_dir}}"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    19
    state: "directory"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    20
    owner: "prometheus"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    21
    group: "prometheus"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    22
    recurse: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    23
  notify: restart prometheus service
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    24
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    25
- name: configure prometheus data dir
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    26
  become: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    27
  lineinfile:
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    28
    path: "/etc/default/prometheus"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    29
    regexp: '^ARGS="'
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    30
    line: 'ARGS="--storage.tsdb.path={{prometheus_server_data_dir}}"'
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    31
  notify: restart prometheus service
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    32
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    33
- name: configure prometheus
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    34
  become: yes
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    35
  template:
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    36
    src: "{{prometheus_server_conf}}"
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    37
    dest: "/etc/prometheus/prometheus.yml"
8
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    38
  notify:
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    39
    - restart prometheus service
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    40
    - restart grafana service
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    41
53
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    42
- name: ensure grafana is started
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    43
  become: yes
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    44
  systemd: name="grafana-server.service" enabled="yes" state="started"
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    45
181
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    46
### TODO: This is broken and not sure why. Started having errors one day. I
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    47
### supect bug with anisble module
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    48
# - name: install grafana prometheus data source
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    49
#   become: yes
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    50
#   grafana_datasource:
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    51
#     name: "Prometheus"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    52
#     ds_type: "prometheus"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    53
#     ds_url: "http://localhost:9090"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    54
#     grafana_url: "http://localhost:3000"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    55
#     is_default: yes
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    56
#   changed_when: false
52
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    57
187
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    58
# - name: install grafana plugins
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    59
#   become: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    60
#   grafana_plugin: name="{{item}}"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    61
#   loop: "{{prometheus_server_grafana_plugins}}"
52
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    62
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    63
- name: copy dashboards to target
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    64
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    65
  copy:
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    66
    src: "{{prometheus_server_grafana_dashboard_src}}/{{item}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    67
    dest: "/tmp/"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    68
    mode: "0640"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    69
  loop: "{{prometheus_server_grafana_dashboards}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    70
187
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    71
- name: install grafana dashboards
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    72
  become: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    73
  grafana_dashboard:
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    74
    grafana_url: "http://localhost:3000"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    75
    path: "/tmp/{{item}}"
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    76
    overwrite: yes
0f3a64c60ec5 Added lnd REST api to nginx. Moved prometheus and apt-cacher data to external hdd.
Luke Hoersten <luke@hoersten.org>
parents: 181
diff changeset
    77
  loop: "{{prometheus_server_grafana_dashboards}}"