diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..47b1801 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,17 @@ +prometheus: + config: + global: + scrape_interval: 15s + evaluation_interval: 15s + external_labels: + monitor: 'example' + alerting: + alertmanagers: + - static_configs: + - targets: ['localhost:9093'] + rule_files: + scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..1ab4473 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - certificates diff --git a/tasks/main.yml b/tasks/main.yml index fd4e97e..c797a92 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,42 @@ - name: install prometheus apt: pkg: prometheus + +- name: update prometheus user + user: + name: prometheus + groups: ssl-cert + append: yes + +- name: wrtie prometheus (base) config + copy: + owner: root + group: root + mode: 0644 + dest: /etc/prometheus/conf.d/prometheus.yml + content: "{{ prometheus.config|to_nice_yaml }}" + +- name: create ssl certificate folder + file: + dest: /etc/prometheus/targetcerts/ + owner: root + group: root + mode: 0755 + state: directory + +- name: create config folders + file: + dest: "{{ item }}" + owner: root + group: root + mode: 0755 + state: directory + loop: + - /etc/prometheus/conf.d + - /etc/prometheus/conf.d/scrape_configs + +- name: add cronjob to regenerate config + cron: + name: regenerate prometheus config + minute: 3,18,33,48 + job: cat /etc/prometheus/conf.d/* /etc/prometheus/conf.d/scrape_configs/* 2> /dev/null > /etc/prometheus/prometheus.yml; /usr/sbin/service prometheus reload diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..748ceb1 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,4 @@ +certificates: + certs: + prometheus_scraper: + backend: selfsigned