prometheus/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 10 Feb 2024 15:40:36 -0600
changeset 229 7e3bf48e516a
parent 223 de03976c2df1
permissions -rw-r--r--
Dendrite tweaks.
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
189
3bd85e235e76 Removed deprecated apt_key ansible module.
Luke Hoersten <luke@hoersten.org>
parents: 187
diff changeset
     5
  get_url:
223
de03976c2df1 Unifi-7.5 release doesnt seem to support arm so I held the version at 7.4.
Luke Hoersten <luke@hoersten.org>
parents: 197
diff changeset
     6
    url: "https://apt.grafana.com/gpg.key"
197
1cc658995a70 Added key signing for apt repos.
Luke Hoersten <luke@hoersten.org>
parents: 189
diff changeset
     7
    dest: "/etc/apt/trusted.gpg.d/grafana.asc"
189
3bd85e235e76 Removed deprecated apt_key ansible module.
Luke Hoersten <luke@hoersten.org>
parents: 187
diff changeset
     8
    mode: "0644"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
- name: add grafana apt repo
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
  become: yes
223
de03976c2df1 Unifi-7.5 release doesnt seem to support arm so I held the version at 7.4.
Luke Hoersten <luke@hoersten.org>
parents: 197
diff changeset
    12
  apt_repository: repo="deb [signed-by=/etc/apt/trusted.gpg.d/grafana.asc] https://apt.grafana.com stable main"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
- name: install prometheus and grafana
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    15
  become: yes
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    16
  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
    17
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
    18
- 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
    19
  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
    20
  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
    21
    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
    22
    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
    23
    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
    24
    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
    25
    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
    26
  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
    27
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
- 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
    29
  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
    30
  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
    31
    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
    32
    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
    33
    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
    34
  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
    35
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    36
- name: configure prometheus
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    37
  become: yes
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    38
  template:
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    39
    src: "{{prometheus_server_conf}}"
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    40
    dest: "/etc/prometheus/prometheus.yml"
8
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    41
  notify:
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    42
    - restart prometheus service
20975062661d Added grafana restart handler.
Luke Hoersten <luke@hoersten.org>
parents: 5
diff changeset
    43
    - restart grafana service
5
4f014cdac0b1 Completed prometheus basic roles.
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    44
53
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    45
- name: ensure grafana is started
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    46
  become: yes
9e4f750f5d36 Disable systemd-resolved to not conflict with adguard home.
Luke Hoersten <luke@hoersten.org>
parents: 52
diff changeset
    47
  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
    48
181
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    49
### 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
    50
### supect bug with anisble module
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    51
# - name: install grafana prometheus data source
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    52
#   become: yes
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    53
#   grafana_datasource:
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    54
#     name: "Prometheus"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    55
#     ds_type: "prometheus"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    56
#     ds_url: "http://localhost:9090"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    57
#     grafana_url: "http://localhost:3000"
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    58
#     is_default: yes
2b30d081dd9b Version updates.
Luke Hoersten <luke@hoersten.org>
parents: 54
diff changeset
    59
#   changed_when: false
52
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    60
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
    61
# - 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
    62
#   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
    63
#   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
    64
#   loop: "{{prometheus_server_grafana_plugins}}"
52
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    65
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    66
- name: copy dashboards to target
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    67
  become: yes
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    68
  copy:
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    69
    src: "{{prometheus_server_grafana_dashboard_src}}/{{item}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    70
    dest: "/tmp/"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    71
    mode: "0640"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    72
  loop: "{{prometheus_server_grafana_dashboards}}"
5a5071d4eaad Added grafana role automation.
Luke Hoersten <luke@hoersten.org>
parents: 8
diff changeset
    73
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
    74
- 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
    75
  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
    76
  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
    77
    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
    78
    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
    79
    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
    80
  loop: "{{prometheus_server_grafana_dashboards}}"