summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/server/tasks
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-05-30 22:28:46 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-06-20 01:44:16 +0200
commite29ce4fdbe2ce669c62777fffa18ae8557e54a73 (patch)
tree8eaedd699b8eb49bc51ec260af5e6abd74a1cce1 /roles/monitoring/prometheus/server/tasks
parentcleanup: old preliminary tasks (diff)
prometheus: initial simple server role
Diffstat (limited to 'roles/monitoring/prometheus/server/tasks')
-rw-r--r--roles/monitoring/prometheus/server/tasks/main.yml48
1 files changed, 47 insertions, 1 deletions
diff --git a/roles/monitoring/prometheus/server/tasks/main.yml b/roles/monitoring/prometheus/server/tasks/main.yml
index ec5bd9a9..ffbc5ffe 100644
--- a/roles/monitoring/prometheus/server/tasks/main.yml
+++ b/roles/monitoring/prometheus/server/tasks/main.yml
@@ -1,4 +1,11 @@
---
+- name: check if prometheus apt component of spreadspace repo is enabled
+ assert:
+ msg: "please enable the 'prometheus' component of spreadspace repo using 'spreadspace_apt_repo_components'"
+ that:
+ - spreadspace_apt_repo_components is defined
+ - "'prometheus' in spreadspace_apt_repo_components"
+
- name: prepare storage volume for /var/lib/prometheus
when: prometheus_server_storage is defined
vars:
@@ -11,6 +18,45 @@
name: prom-server
state: present
+- name: create configuration directories
+ loop:
+ - rules
+ - targets
+ file:
+ path: "/etc/prometheus/{{ item }}"
+ state: directory
+
+- name: generate configuration file
+ template:
+ src: prometheus.yml.j2
+ dest: /etc/prometheus/prometheus.yml
+
+- name: add user for server
+ user:
+ name: prometheus
+ system: yes
+ home: /var/lib/prometheus
+ create_home: no
+
+- name: create data directory
+ file:
+ path: /var/lib/prometheus/metrics2
+ state: directory
+ owner: prometheus
+ group: prometheus
+
## TODO:
-## - systemd service unit
## - create CA and certificate/key
+
+- name: generate systemd service unit
+ template:
+ src: prometheus.service.j2
+ dest: /etc/systemd/system/prometheus.service
+ notify: restart prometheus
+
+- name: make sure prometheus is enabled and started
+ systemd:
+ name: prometheus.service
+ daemon_reload: yes
+ state: started
+ enabled: yes