mirror of
https://gitlab.com/s3lph/ansible-collection-prometheus
synced 2024-11-23 02:01:10 +01:00
Remove dnsbl_exporter; use FQCNs everywhere
This commit is contained in:
parent
6927906cbb
commit
c6f6440598
26 changed files with 111 additions and 177 deletions
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: restart alertmanager
|
- name: restart alertmanager
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: prometheus-alertmanager.service
|
name: prometheus-alertmanager.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: reload alertmanager
|
- name: reload alertmanager
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: prometheus-alertmanager.service
|
name: prometheus-alertmanager.service
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: render alertmanager runtime arguments
|
- name: render alertmanager runtime arguments
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/default/prometheus-alertmanager
|
path: /etc/default/prometheus-alertmanager
|
||||||
regexp: "^ARGS=.*$"
|
regexp: "^ARGS=.*$"
|
||||||
line: >-
|
line: >-
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
notify: restart alertmanager
|
notify: restart alertmanager
|
||||||
|
|
||||||
- name: render alertmanager config template
|
- name: render alertmanager config template
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: alertmanager.yml.j2
|
src: alertmanager.yml.j2
|
||||||
dest: /etc/prometheus/alertmanager.yml
|
dest: /etc/prometheus/alertmanager.yml
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
notify: reload alertmanager
|
notify: reload alertmanager
|
||||||
|
|
||||||
- name: render alertmanager notification templates
|
- name: render alertmanager notification templates
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ item.content }}"
|
content: "{{ item.content }}"
|
||||||
dest: "{{ item.path }}"
|
dest: "{{ item.path }}"
|
||||||
owner: root
|
owner: root
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: install alertmanager
|
- name: install alertmanager
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: prometheus-alertmanager
|
name: prometheus-alertmanager
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: start and enable alertmanager
|
- name: start and enable alertmanager
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-alertmanager.service
|
name: prometheus-alertmanager.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
prometheus_dnsbl_exporter_rbls: []
|
|
||||||
prometheus_dnsbl_exporter_args: ""
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- name: restart prometheus-dnsbl-exporter
|
|
||||||
service:
|
|
||||||
name: prometheus-dnsbl-exporter
|
|
||||||
state: restarted
|
|
|
@ -1,27 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- name: render /etc/default/prometheus-dnsbl-exporter
|
|
||||||
template:
|
|
||||||
src: etc/default/prometheus-dnsbl-exporter.j2
|
|
||||||
dest: /etc/default/prometheus-dnsbl-exporter
|
|
||||||
notify: restart prometheus-dnsbl-exporter
|
|
||||||
|
|
||||||
- name: render rbls.ini
|
|
||||||
template:
|
|
||||||
src: etc/prometheus/dnsbl-exporter/rbls.ini.j2
|
|
||||||
dest: /etc/prometheus/dnsbl-exporter/rbls.ini
|
|
||||||
vars:
|
|
||||||
rbls: "{{ prometheus_dnsbl_exporter_rbls }}"
|
|
||||||
notify: restart prometheus-dnsbl-exporter
|
|
||||||
|
|
||||||
- name: render targets.ini
|
|
||||||
template:
|
|
||||||
src: etc/prometheus/dnsbl-exporter/targets.ini.j2
|
|
||||||
dest: /etc/prometheus/dnsbl-exporter/targets.ini
|
|
||||||
notify: restart prometheus-dnsbl-exporter
|
|
||||||
|
|
||||||
- name: start and enable prometheus-dnsbl-exporter
|
|
||||||
service:
|
|
||||||
name: prometheus-dnsbl-exporter
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
|
@ -1,26 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- name: add s3lphrepo apt key
|
|
||||||
apt_key:
|
|
||||||
data: |
|
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
|
|
||||||
mDMEXu0vYhYJKwYBBAHaRw8BAQdAavB6HHoI15+Dh4ackdZuCjRkPzWcG64DHVxu
|
|
||||||
C2yDFfG0X3MzbHBoJ3MgQ3VzdG9tIERlYmlhbiBSZXBvc2l0b3J5IChBdXRvbWF0
|
|
||||||
ZWQgUGlwZWxpbmUpIDxhY2NvdW50LWdpdGxhYi1pZGV5bml6dkBrZXJuZWxwYW5p
|
|
||||||
Yy5sb2w+iJAEExYIADgWIQQ/Y+h7ABiB4vyzwPu8TSozeH+lRAUCXu0vYgIbAwUL
|
|
||||||
CQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRC8TSozeH+lRNzVAPsEKmhB0kl5Toyj
|
|
||||||
fBPUAJ6Fr+0ljZwoj1oR16Kl9GvkzQD/XqsZC+sYSImXhDTx6iDXm1WYycgB7Abt
|
|
||||||
1dm6aN640gU=
|
|
||||||
=YLAj
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
|
||||||
|
|
||||||
- name: add s3lphrepo
|
|
||||||
apt_repository:
|
|
||||||
repo: deb https://kernelpanic.lol/repo stable main
|
|
||||||
filename: s3lphrepo
|
|
||||||
|
|
||||||
- name: install prometheus-dnsbl-exporter
|
|
||||||
package:
|
|
||||||
name: prometheus-dnsbl-exporter
|
|
||||||
state: present
|
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- import_tasks: install.yml
|
|
||||||
tags:
|
|
||||||
- "role::dnsbl_exporter"
|
|
||||||
- "role::dnsbl_exporter:install"
|
|
||||||
|
|
||||||
- import_tasks: config.yml
|
|
||||||
tags:
|
|
||||||
- "role::dnsbl_exporter"
|
|
||||||
- "role::dnsbl_exporter:config"
|
|
|
@ -1,3 +0,0 @@
|
||||||
{{ ansible_managed | comment }}
|
|
||||||
|
|
||||||
ARGS="--config.rbls=/etc/prometheus/dnsbl-exporter/rbls.ini --config.targets=/etc/prometheus/dnsbl-exporter/targets.ini {{ prometheus_dnsbl_exporter_args }}"
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{ ansible_managed | comment }}
|
|
||||||
|
|
||||||
[rbl]
|
|
||||||
{% for rbl in rbls %}
|
|
||||||
server={{ rbl }}
|
|
||||||
{% endfor %}
|
|
|
@ -1,8 +0,0 @@
|
||||||
{{ ansible_managed | comment }}
|
|
||||||
|
|
||||||
[targets]
|
|
||||||
{% for host in hostvars.keys() %}
|
|
||||||
{% if hostvars[host].monitor_dnsbl | default('false') | bool %}
|
|
||||||
server={{ host }}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: restart prometheus
|
- name: restart prometheus
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus.service
|
name: prometheus.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: restart blackbox exporter
|
- name: restart blackbox exporter
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-blackbox-exporter-local.service
|
name: prometheus-blackbox-exporter-local.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: initialize list of blackbox modules
|
- name: initialize list of blackbox modules
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
_blackbox_modules: {}
|
_blackbox_modules: {}
|
||||||
|
|
||||||
- name: build list of blackbox modules
|
- name: build list of blackbox modules
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
_blackbox_modules: "{% set _ = _blackbox_modules.update(item) %}{{ _blackbox_modules }}"
|
_blackbox_modules: "{% set _ = _blackbox_modules.update(item) %}{{ _blackbox_modules }}"
|
||||||
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | map(attribute='blackbox') | map(attribute='modules') | select('defined') | list }}"
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | map(attribute='blackbox') | map(attribute='modules') | select('defined') | list }}"
|
||||||
|
|
||||||
- name: render blackbox exporter configuration
|
- name: render blackbox exporter configuration
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: blackbox.yml
|
src: blackbox.yml
|
||||||
dest: /etc/prometheus/blackbox.yml
|
dest: /etc/prometheus/blackbox.yml
|
||||||
owner: root
|
owner: root
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: enable prometheus admin api
|
- name: enable prometheus admin api
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/default/prometheus
|
path: /etc/default/prometheus
|
||||||
regexp: "^ARGS=.*$"
|
regexp: "^ARGS=.*$"
|
||||||
line: >-
|
line: >-
|
||||||
|
@ -10,14 +10,14 @@
|
||||||
notify: restart prometheus
|
notify: restart prometheus
|
||||||
|
|
||||||
- name: flush handlers
|
- name: flush handlers
|
||||||
meta: flush_handlers
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
- name: wait
|
- name: wait
|
||||||
pause:
|
ansible.builtin.pause:
|
||||||
seconds: 15
|
seconds: 15
|
||||||
|
|
||||||
- name: clear prometheus time series database
|
- name: clear prometheus time series database
|
||||||
uri:
|
ansible.builtin.uri:
|
||||||
url: http://127.0.0.1:9090/api/v1/admin/tsdb/delete_series?match[]=%7B__name__%3D~%22.%2B%22%7D
|
url: http://127.0.0.1:9090/api/v1/admin/tsdb/delete_series?match[]=%7B__name__%3D~%22.%2B%22%7D
|
||||||
method: POST
|
method: POST
|
||||||
status_code:
|
status_code:
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
- 204
|
- 204
|
||||||
|
|
||||||
- name: wait
|
- name: wait
|
||||||
pause:
|
ansible.builtin.pause:
|
||||||
seconds: 5
|
seconds: 5
|
||||||
|
|
||||||
- name: disable prometheus admin api
|
- name: disable prometheus admin api
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/default/prometheus
|
path: /etc/default/prometheus
|
||||||
regexp: "^ARGS=.*$"
|
regexp: "^ARGS=.*$"
|
||||||
line: >-
|
line: >-
|
||||||
|
@ -38,4 +38,4 @@
|
||||||
notify: restart prometheus
|
notify: restart prometheus
|
||||||
|
|
||||||
- name: flush handlers
|
- name: flush handlers
|
||||||
meta: flush_handlers
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: install prometheus
|
- name: install prometheus
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
- name: start and enable prometheus
|
- name: start and enable prometheus
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus.service
|
name: prometheus.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: download blackbox exporter
|
- name: download blackbox exporter
|
||||||
get_url:
|
ansible.builtin.get_url:
|
||||||
url: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ prometheus_blackbox_exporter_version }}/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.linux-amd64.tar.gz" # noqa 204
|
url: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ prometheus_blackbox_exporter_version }}/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.linux-amd64.tar.gz" # noqa 204
|
||||||
dest: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.tar.gz"
|
dest: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.tar.gz"
|
||||||
|
|
||||||
- name: unpack blackbox exporter
|
- name: unpack blackbox exporter
|
||||||
unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.tar.gz"
|
src: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.tar.gz"
|
||||||
dest: "/root"
|
dest: "/root"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
|
||||||
- name: install blackbox exporter
|
- name: install blackbox exporter
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.linux-amd64/blackbox_exporter"
|
src: "/root/blackbox_exporter-{{ prometheus_blackbox_exporter_version }}.linux-amd64/blackbox_exporter"
|
||||||
dest: /usr/local/bin/prometheus-blackbox-exporter
|
dest: /usr/local/bin/prometheus-blackbox-exporter
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: install blackbox exporter defaults file
|
- name: install blackbox exporter defaults file
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: etc-defaults-blackbox
|
src: etc-defaults-blackbox
|
||||||
dest: /etc/default/prometheus-blackbox-exporter
|
dest: /etc/default/prometheus-blackbox-exporter
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
- name: install blackbox exporter service
|
- name: install blackbox exporter service
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-blackbox-exporter-local.service
|
src: prometheus-blackbox-exporter-local.service
|
||||||
dest: /etc/systemd/system/prometheus-blackbox-exporter-local.service
|
dest: /etc/systemd/system/prometheus-blackbox-exporter-local.service
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -49,13 +49,13 @@
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
- name: stop and diable native blackbox exporter
|
- name: stop and diable native blackbox exporter
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-blackbox-exporter.service
|
name: prometheus-blackbox-exporter.service
|
||||||
state: stopped
|
state: stopped
|
||||||
enabled: no
|
enabled: no
|
||||||
|
|
||||||
- name: start and enable blackbox exporter
|
- name: start and enable blackbox exporter
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-blackbox-exporter-local.service
|
name: prometheus-blackbox-exporter-local.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
- name: create config fragment directory
|
- name: create config fragment directory
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ playbook_dir }}/.prometheus/{{ item }}.d"
|
path: "{{ playbook_dir }}/.prometheus/{{ item }}.d"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: 0755
|
||||||
loop:
|
loop:
|
||||||
- conf
|
- conf
|
||||||
- alerts
|
- alerts
|
||||||
|
|
||||||
- name: list current config fragments
|
- name: list current config fragments
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
find:
|
ansible.builtin.find:
|
||||||
paths:
|
paths:
|
||||||
- "{{ playbook_dir }}/.prometheus/conf.d/"
|
- "{{ playbook_dir }}/.prometheus/conf.d/"
|
||||||
- "{{ playbook_dir }}/.prometheus/alerts.d/"
|
- "{{ playbook_dir }}/.prometheus/alerts.d/"
|
||||||
|
@ -22,23 +23,25 @@
|
||||||
register: prometheus_register_current_fragments
|
register: prometheus_register_current_fragments
|
||||||
|
|
||||||
- name: process current config fragments
|
- name: process current config fragments
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
prometheus_register_current_fragments:
|
prometheus_register_current_fragments:
|
||||||
"{{ prometheus_register_current_fragments.files | map(attribute='path') | list }}"
|
"{{ prometheus_register_current_fragments.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
- name: render prometheus base config
|
- name: render prometheus base config
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-base.yml
|
src: prometheus-base.yml
|
||||||
dest: "{{ playbook_dir }}/.prometheus/conf.d/00-base.yml"
|
dest: "{{ playbook_dir }}/.prometheus/conf.d/00-base.yml"
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: render prometheus job configs
|
- name: render prometheus job configs
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-job.yml
|
src: prometheus-job.yml
|
||||||
dest: "{{ playbook_dir }}/.prometheus/conf.d/{{ '%02d' | format(counter+1) }}-job-{{ item.name }}.yml"
|
dest: "{{ playbook_dir }}/.prometheus/conf.d/{{ '%02d' | format(counter+1) }}-job-{{ item.name }}.yml"
|
||||||
|
mode: 0644
|
||||||
vars:
|
vars:
|
||||||
job: "{{ item }}"
|
job: "{{ item }}"
|
||||||
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
|
||||||
|
@ -47,60 +50,64 @@
|
||||||
register: prometheus_register_new_config_fragments
|
register: prometheus_register_new_config_fragments
|
||||||
|
|
||||||
- name: remove newly created files from deletion list
|
- name: remove newly created files from deletion list
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
prometheus_register_current_fragments:
|
prometheus_register_current_fragments:
|
||||||
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_config_fragments.results | map(attribute='dest') | list) }}"
|
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_config_fragments.results | map(attribute='dest') | list) }}"
|
||||||
|
|
||||||
- name: render prometheus alert base config
|
- name: render prometheus alert base config
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-alert-base.yml
|
src: prometheus-alert-base.yml
|
||||||
dest: .prometheus/alerts.d/00-base.yml
|
dest: .prometheus/alerts.d/00-base.yml
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: render prometheus alert configs
|
- name: render prometheus alert configs
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ item.alerts | to_nice_yaml(indent=2) | indent(2, first=true) }}"
|
content: "{{ item.alerts | to_nice_yaml(indent=2) | indent(2, first=true) }}"
|
||||||
dest: "{{ playbook_dir }}/.prometheus/alerts.d/{{ '%02d' | format(counter+1) }}-alert-{{ item.name }}.yml"
|
dest: "{{ playbook_dir }}/.prometheus/alerts.d/{{ '%02d' | format(counter+1) }}-alert-{{ item.name }}.yml"
|
||||||
|
mode: 0644
|
||||||
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
index_var: counter
|
index_var: counter
|
||||||
register: prometheus_register_new_alert_fragments
|
register: prometheus_register_new_alert_fragments
|
||||||
|
|
||||||
- name: remove newly created files from deletion list
|
- name: remove newly created files from deletion list
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
prometheus_register_current_fragments:
|
prometheus_register_current_fragments:
|
||||||
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_alert_fragments.results | map(attribute='dest') | list) }}"
|
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_alert_fragments.results | map(attribute='dest') | list) }}"
|
||||||
|
|
||||||
- name: render host-specific prometheus alert configs
|
- name: render host-specific prometheus alert configs
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ hostvars[item].prometheus_host_specific_alerts | to_nice_yaml(indent=2) | indent(2, first=true) }}"
|
content: "{{ hostvars[item].prometheus_host_specific_alerts | to_nice_yaml(indent=2) | indent(2, first=true) }}"
|
||||||
dest: "{{ playbook_dir }}/.prometheus/alerts.d/{{ '99-host-%s' | format(hostvars[item].inventory_hostname) }}-alerts.yml"
|
dest: "{{ playbook_dir }}/.prometheus/alerts.d/{{ '99-host-%s' | format(hostvars[item].inventory_hostname) }}-alerts.yml"
|
||||||
|
mode: 0644
|
||||||
when: "'prometheus_host_specific_alerts' in hostvars[item]"
|
when: "'prometheus_host_specific_alerts' in hostvars[item]"
|
||||||
loop: "{{ hostvars.keys() | list }}"
|
loop: "{{ hostvars.keys() | list }}"
|
||||||
register: prometheus_register_new_host_specific_alert_fragments
|
register: prometheus_register_new_host_specific_alert_fragments
|
||||||
|
|
||||||
- name: remove newly created files from deletion list
|
- name: remove newly created files from deletion list
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
prometheus_register_current_fragments:
|
prometheus_register_current_fragments:
|
||||||
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_host_specific_alert_fragments.results | selectattr('dest', 'defined') | map(attribute='dest') | list) }}" # noqa 204
|
"{{ prometheus_register_current_fragments | difference(prometheus_register_new_host_specific_alert_fragments.results | selectattr('dest', 'defined') | map(attribute='dest') | list) }}" # noqa 204
|
||||||
|
|
||||||
- name: delete old config fragments
|
- name: delete old config fragments
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop: "{{ prometheus_register_current_fragments }}"
|
loop: "{{ prometheus_register_current_fragments }}"
|
||||||
|
|
||||||
- name: assemble fragment directories
|
- name: assemble fragment directories
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
assemble:
|
ansible.builtin.assemble:
|
||||||
src: "{{ playbook_dir }}/.prometheus/{{ item.local }}.d/"
|
src: "{{ playbook_dir }}/.prometheus/{{ item.local }}.d/"
|
||||||
dest: "{{ playbook_dir }}/.prometheus/{{ item.remote }}.yml"
|
dest: "{{ playbook_dir }}/.prometheus/{{ item.remote }}.yml"
|
||||||
delimiter: "\n\n"
|
delimiter: "\n\n"
|
||||||
|
mode: 0644
|
||||||
loop:
|
loop:
|
||||||
- local: conf
|
- local: conf
|
||||||
remote: prometheus
|
remote: prometheus
|
||||||
|
@ -108,7 +115,7 @@
|
||||||
remote: alert_rules
|
remote: alert_rules
|
||||||
|
|
||||||
- name: upload config files to host
|
- name: upload config files to host
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ playbook_dir }}/.prometheus/prometheus.yml"
|
src: "{{ playbook_dir }}/.prometheus/prometheus.yml"
|
||||||
dest: "/etc/prometheus/prometheus.yml"
|
dest: "/etc/prometheus/prometheus.yml"
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -118,7 +125,7 @@
|
||||||
notify: restart prometheus
|
notify: restart prometheus
|
||||||
|
|
||||||
- name: upload alert config file to host
|
- name: upload alert config file to host
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ playbook_dir }}/.prometheus/alert_rules.yml"
|
src: "{{ playbook_dir }}/.prometheus/alert_rules.yml"
|
||||||
dest: "/etc/prometheus/alert_rules.yml"
|
dest: "/etc/prometheus/alert_rules.yml"
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -128,7 +135,7 @@
|
||||||
notify: restart prometheus
|
notify: restart prometheus
|
||||||
|
|
||||||
- name: configure prometheus lookback delta
|
- name: configure prometheus lookback delta
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/default/prometheus
|
path: /etc/default/prometheus
|
||||||
regexp: "^ARGS=.*$"
|
regexp: "^ARGS=.*$"
|
||||||
line: >-
|
line: >-
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: ucr commit
|
- name: ucr commit
|
||||||
command: /usr/sbin/ucr commit
|
ansible.builtin.command: /usr/sbin/ucr commit
|
||||||
|
|
||||||
- name: systemctl daemon-reload
|
- name: systemctl daemon-reload
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
|
|
||||||
- name: restart prometheus-zpool-collector
|
- name: restart prometheus-zpool-collector
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-zpool.timer
|
name: prometheus-node-exporter-zpool.timer
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: restart prometheus-node-exporter
|
- name: restart prometheus-node-exporter
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter.service
|
name: prometheus-node-exporter.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: install collector script
|
- name: install collector script
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "{{ basename }}.j2"
|
src: "{{ basename }}.j2"
|
||||||
dest: "/usr/local/bin/{{ basename }}"
|
dest: "/usr/local/bin/{{ basename }}"
|
||||||
|
owner: root
|
||||||
|
group: prometheus
|
||||||
mode: 0750
|
mode: 0750
|
||||||
vars:
|
vars:
|
||||||
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
|
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
|
||||||
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
||||||
|
|
||||||
- name: install collector config
|
- name: install collector config
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ item.value.config.content }}"
|
content: "{{ item.value.config.content }}"
|
||||||
dest: "{{ item.value.config.filename }}"
|
dest: "{{ item.value.config.filename }}"
|
||||||
|
owner: root
|
||||||
|
group: prometheus
|
||||||
|
mode: 0640
|
||||||
when: "'config' in item.value"
|
when: "'config' in item.value"
|
||||||
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
||||||
|
|
||||||
- name: install collector service
|
- name: install collector service
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "prometheus-collector.service.j2"
|
src: "prometheus-collector.service.j2"
|
||||||
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.service"
|
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.service"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
vars:
|
vars:
|
||||||
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
|
basename: "{{ item.value.template_base_name | default('prometheus-node-exporter-' + item.key + '.sh') }}"
|
||||||
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
||||||
|
@ -27,15 +35,18 @@
|
||||||
- systemctl daemon-reload
|
- systemctl daemon-reload
|
||||||
|
|
||||||
- name: install collector timer
|
- name: install collector timer
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: "prometheus-collector.timer.j2"
|
src: "prometheus-collector.timer.j2"
|
||||||
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.timer"
|
dest: "/etc/systemd/system/prometheus-node-exporter-{{ item.key }}.timer"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
loop: "{{ prometheus_textfile_collectors | dict2items }}"
|
||||||
notify:
|
notify:
|
||||||
- systemctl daemon-reload
|
- systemctl daemon-reload
|
||||||
|
|
||||||
- name: start and enable collector timer
|
- name: start and enable collector timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: "prometheus-node-exporter-{{ item.key }}.timer"
|
name: "prometheus-node-exporter-{{ item.key }}.timer"
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: create /etc/prometheus/node-exporter/tls
|
- name: create /etc/prometheus/node-exporter/tls
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /etc/prometheus/node-exporter/tls
|
path: /etc/prometheus/node-exporter/tls
|
||||||
state: directory
|
state: directory
|
||||||
owner: prometheus
|
owner: prometheus
|
||||||
group: prometheus
|
group: prometheus
|
||||||
|
mode: 0750
|
||||||
|
|
||||||
- name: render /etc/prometheus/node-exporter/tls/config.yml
|
- name: render /etc/prometheus/node-exporter/tls/config.yml
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-node-exporter-webconfig.yml.j2
|
src: prometheus-node-exporter-webconfig.yml.j2
|
||||||
dest: /etc/prometheus/node-exporter/tls/config.yml
|
dest: /etc/prometheus/node-exporter/tls/config.yml
|
||||||
owner: prometheus
|
owner: prometheus
|
||||||
group: prometheus
|
group: prometheus
|
||||||
|
mode: 0640
|
||||||
notify: restart prometheus-node-exporter
|
notify: restart prometheus-node-exporter
|
||||||
|
|
||||||
- name: render /etc/default/prometheus-node-exporter
|
- name: render /etc/default/prometheus-node-exporter
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-node-exporter.default.j2
|
src: prometheus-node-exporter.default.j2
|
||||||
dest: /etc/default/prometheus-node-exporter
|
dest: /etc/default/prometheus-node-exporter
|
||||||
|
owner: root
|
||||||
|
group: prometheus
|
||||||
|
mode: 0640
|
||||||
vars:
|
vars:
|
||||||
args: "{{ prometheus_node_exporter_args }}"
|
args: "{{ prometheus_node_exporter_args }}"
|
||||||
notify: restart prometheus-node-exporter
|
notify: restart prometheus-node-exporter
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
- name: check if package files already exist
|
- name: check if package files already exist
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
||||||
loop:
|
loop:
|
||||||
- name: prometheus-node-exporter
|
- name: prometheus-node-exporter
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
register: prometheus_node_register_ucs_deb_stat
|
register: prometheus_node_register_ucs_deb_stat
|
||||||
|
|
||||||
- name: download packages
|
- name: download packages
|
||||||
get_url:
|
ansible.builtin.get_url:
|
||||||
url: "https://{{ debian_mirror }}/debian/pool/main/{{ pfirst | urlencode() }}/{{ package | urlencode() }}/{{ package | urlencode() }}_{{ version | urlencode() }}_{{ arch | urlencode() }}.deb" # noqa 204
|
url: "https://{{ debian_mirror }}/debian/pool/main/{{ pfirst | urlencode() }}/{{ package | urlencode() }}/{{ package | urlencode() }}_{{ version | urlencode() }}_{{ arch | urlencode() }}.deb" # noqa 204
|
||||||
dest: "/root/{{ package }}_{{ version }}_{{ arch }}.deb"
|
dest: "/root/{{ package }}_{{ version }}_{{ arch }}.deb"
|
||||||
vars:
|
vars:
|
||||||
|
@ -26,31 +26,31 @@
|
||||||
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
||||||
|
|
||||||
- name: install packages
|
- name: install packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
||||||
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
||||||
|
|
||||||
- name: start prometheus-node-exporter.service
|
- name: start prometheus-node-exporter.service
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter.service
|
name: prometheus-node-exporter.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-apt.timer
|
- name: start prometheus-node-exporter-apt.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-apt.timer
|
name: prometheus-node-exporter-apt.timer
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: install smartmontools
|
- name: install smartmontools
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: smartmontools
|
name: smartmontools
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_virtualization_role == 'host'
|
- ansible_virtualization_role == 'host'
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-smartmon.timer
|
- name: start prometheus-node-exporter-smartmon.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-smartmon.timer
|
name: prometheus-node-exporter-smartmon.timer
|
||||||
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
||||||
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: install prometheus-node-exporter
|
- name: install prometheus-node-exporter
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
@ -10,26 +10,26 @@
|
||||||
- prometheus-node-exporter-collectors
|
- prometheus-node-exporter-collectors
|
||||||
|
|
||||||
- name: start prometheus-node-exporter.service
|
- name: start prometheus-node-exporter.service
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter.service
|
name: prometheus-node-exporter.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-apt.timer
|
- name: start prometheus-node-exporter-apt.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-apt.timer
|
name: prometheus-node-exporter-apt.timer
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: install smartmontools
|
- name: install smartmontools
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: smartmontools
|
name: smartmontools
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_virtualization_role == 'host'
|
- ansible_virtualization_role == 'host'
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-smartmon.timer
|
- name: start prometheus-node-exporter-smartmon.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-smartmon.timer
|
name: prometheus-node-exporter-smartmon.timer
|
||||||
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
||||||
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: check if package files already exist
|
- name: check if package files already exist
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
||||||
loop:
|
loop:
|
||||||
- name: prometheus-node-exporter
|
- name: prometheus-node-exporter
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
register: prometheus_node_register_ucs_deb_stat
|
register: prometheus_node_register_ucs_deb_stat
|
||||||
|
|
||||||
- name: download packages
|
- name: download packages
|
||||||
get_url:
|
ansible.builtin.get_url:
|
||||||
url: "https://{{ debian_mirror }}/debian/pool/main/{{ pfirst | urlencode() }}/{{ package | urlencode() }}/{{ package | urlencode() }}_{{ version | urlencode() }}_{{ arch | urlencode() }}.deb" # noqa 204
|
url: "https://{{ debian_mirror }}/debian/pool/main/{{ pfirst | urlencode() }}/{{ package | urlencode() }}/{{ package | urlencode() }}_{{ version | urlencode() }}_{{ arch | urlencode() }}.deb" # noqa 204
|
||||||
dest: "/root/{{ package }}_{{ version }}_{{ arch }}.deb"
|
dest: "/root/{{ package }}_{{ version }}_{{ arch }}.deb"
|
||||||
vars:
|
vars:
|
||||||
|
@ -28,37 +28,37 @@
|
||||||
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
||||||
|
|
||||||
- name: install packages
|
- name: install packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
||||||
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
||||||
|
|
||||||
- name: start prometheus-node-exporter.service
|
- name: start prometheus-node-exporter.service
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter.service
|
name: prometheus-node-exporter.service
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-apt.timer
|
- name: start prometheus-node-exporter-apt.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-apt.timer
|
name: prometheus-node-exporter-apt.timer
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: install smartmontools
|
- name: install smartmontools
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: smartmontools
|
name: smartmontools
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_virtualization_role == 'host'
|
- ansible_virtualization_role == 'host'
|
||||||
|
|
||||||
- name: start prometheus-node-exporter-smartmon.timer
|
- name: start prometheus-node-exporter-smartmon.timer
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: prometheus-node-exporter-smartmon.timer
|
name: prometheus-node-exporter-smartmon.timer
|
||||||
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
||||||
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
||||||
|
|
||||||
- name: check firewall settings in ucr
|
- name: check firewall settings in ucr
|
||||||
command: "/usr/sbin/ucr get {{ item.name }}"
|
ansible.builtin.command: "/usr/sbin/ucr get {{ item.name }}"
|
||||||
changed_when: no
|
changed_when: no
|
||||||
check_mode: no
|
check_mode: no
|
||||||
loop:
|
loop:
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
register: prometheus_node_register_ucs_ucr
|
register: prometheus_node_register_ucs_ucr
|
||||||
|
|
||||||
- name: set firewall settings in ucr
|
- name: set firewall settings in ucr
|
||||||
command: "/usr/sbin/ucr set {{ item.item.name }}={{ item.item.value }}"
|
ansible.builtin.command: "/usr/sbin/ucr set {{ item.item.name }}={{ item.item.value }}"
|
||||||
changed_when: yes
|
changed_when: yes
|
||||||
notify:
|
notify:
|
||||||
- ucr commit
|
- ucr commit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: start node exporter
|
- name: start node exporter
|
||||||
command: /usr/sbin/rcctl start node_exporter
|
ansible.builtin.command: /usr/sbin/rcctl start node_exporter
|
||||||
|
|
||||||
- name: restart node exporter
|
- name: restart node exporter
|
||||||
command: /usr/sbin/rcctl restart node_exporter
|
ansible.builtin.command: /usr/sbin/rcctl restart node_exporter
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: create /etc/prometheus/node-exporter/tls
|
- name: create /etc/prometheus/node-exporter/tls
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /etc/prometheus/node-exporter/tls
|
path: /etc/prometheus/node-exporter/tls
|
||||||
state: directory
|
state: directory
|
||||||
owner: _nodeexporter
|
owner: _nodeexporter
|
||||||
group: _nodeexporter
|
group: _nodeexporter
|
||||||
|
mode: 0750
|
||||||
|
|
||||||
- name: render /etc/prometheus/node-exporter/tls/config.yml
|
- name: render /etc/prometheus/node-exporter/tls/config.yml
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: prometheus-node-exporter-webconfig.yml.j2
|
src: prometheus-node-exporter-webconfig.yml.j2
|
||||||
dest: /etc/prometheus/node-exporter/tls/config.yml
|
dest: /etc/prometheus/node-exporter/tls/config.yml
|
||||||
owner: _nodeexporter
|
owner: _nodeexporter
|
||||||
group: _nodeexporter
|
group: _nodeexporter
|
||||||
|
mode: 0640
|
||||||
notify: restart node exporter
|
notify: restart node exporter
|
||||||
|
|
||||||
- name: configure node exporter
|
- name: configure node exporter
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/rc.conf.local
|
path: /etc/rc.conf.local
|
||||||
line: >-
|
line: >-
|
||||||
node_exporter_flags=--collector.textfile.directory={{ node_exporter_textfile_dir }}
|
node_exporter_flags=--collector.textfile.directory={{ node_exporter_textfile_dir }}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: install prometheus node exporter
|
- name: install prometheus node exporter
|
||||||
openbsd_pkg:
|
community.general.openbsd_pkg:
|
||||||
name: node_exporter
|
name: node_exporter
|
||||||
|
|
||||||
- name: create textfile collector directory
|
- name: create textfile collector directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ node_exporter_textfile_dir }}"
|
path: "{{ node_exporter_textfile_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: create syspatch check script
|
- name: create syspatch check script
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: syspatch.sh.j2
|
src: syspatch.sh.j2
|
||||||
dest: /usr/local/bin/prometheus-node-exporter-syspatch.sh
|
dest: /usr/local/bin/prometheus-node-exporter-syspatch.sh
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: register syspatch check script in cron
|
- name: register syspatch check script in cron
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/daily.local
|
path: /etc/daily.local
|
||||||
regexp: '^/usr/local/bin/prometheus-node-exporter-syspatch.sh$'
|
regexp: '^/usr/local/bin/prometheus-node-exporter-syspatch.sh$'
|
||||||
line: '/usr/local/bin/prometheus-node-exporter-syspatch.sh'
|
line: '/usr/local/bin/prometheus-node-exporter-syspatch.sh'
|
||||||
|
|
Loading…
Reference in a new issue