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.

---

- name: add grafana apt key
  become: yes
  apt_key: url="https://packages.grafana.com/gpg.key"

- name: add grafana apt repo
  become: yes
  apt_repository: repo="deb https://packages.grafana.com/oss/deb stable main"

- name: install prometheus and grafana
  become: yes
  apt: name="{{prometheus_server_apt_packages}}" state="latest"

- name: configure prometheus
  become: yes
  template:
    src: "{{prometheus_server_conf}}"
    dest: "/etc/prometheus/prometheus.yml"
  notify:
    - restart prometheus service
    - restart grafana service

- name: install grafana prometheus data source
  become: yes
  grafana_datasource:
    name: "Prometheus"
    ds_type: "prometheus"
    ds_url: "http://localhost:9090"
    grafana_url: "http://localhost:3000"
    is_default: yes

- name: install grafana plugins
  become: yes
  grafana_plugin: name="{{item}}"
  loop: "{{prometheus_server_grafana_plugins}}"

- name: copy dashboards to target
  become: yes
  copy:
    src: "{{prometheus_server_grafana_dashboard_src}}/{{item}}"
    dest: "/tmp/"
    mode: "0640"
  loop: "{{prometheus_server_grafana_dashboards}}"

- name: install grafana dashboards
  become: yes
  grafana_dashboard:
    grafana_url: "http://localhost:3000"
    path: "/tmp/{{item}}"
  loop: "{{prometheus_server_grafana_dashboards}}"