role service-prometheus: change handlers from reload to restart and add handler to reload systemd units

This commit is contained in:
Julian Labus 2018-09-11 14:11:20 +02:00
parent 07ab6837fe
commit ee634b5397
No known key found for this signature in database
GPG key ID: 8AF209F2C6B3572A
4 changed files with 26 additions and 8 deletions

View file

@ -1,9 +1,18 @@
- name: reload prometheus - name: reload systemd
systemd:
daemon_reload: yes
- name: restart prometheus
service: service:
name: prometheus name: prometheus
state: reloaded state: restarted
- name: reload alertmanager - name: restart alertmanager
service: service:
name: alertmanager name: alertmanager
state: reloaded state: restarted
- name: restart node_exporter
service:
name: node_exporter
state: restarted

View file

@ -46,13 +46,16 @@
template: template:
src: "alertmanager.service.j2" src: "alertmanager.service.j2"
dest: "/lib/systemd/system/alertmanager.service" dest: "/lib/systemd/system/alertmanager.service"
notify:
- reload systemd
- restart alertmanager
- name: install alertmanager config file - name: install alertmanager config file
copy: copy:
src: "alertmanager.yml" src: "alertmanager.yml"
dest: "{{ prometheus_config_path }}/alertmanager.yml" dest: "{{ prometheus_config_path }}/alertmanager.yml"
notify: notify:
- reload alertmanager - restart alertmanager
- name: enable alertmanager service - name: enable alertmanager service
service: service:

View file

@ -32,6 +32,9 @@
template: template:
src: "../templates/node_exporter.service.j2" src: "../templates/node_exporter.service.j2"
dest: "/lib/systemd/system/node_exporter.service" dest: "/lib/systemd/system/node_exporter.service"
notify:
- reload systemd
- restart node_exporter
- name: enable node_exporter service - name: enable node_exporter service
service: service:

View file

@ -44,6 +44,9 @@
template: template:
src: "prometheus.service.j2" src: "prometheus.service.j2"
dest: "/lib/systemd/system/prometheus.service" dest: "/lib/systemd/system/prometheus.service"
notify:
- reload systemd
- restart prometheus
- name: copy rule files from playbook's, if any - name: copy rule files from playbook's, if any
copy: copy:
@ -52,7 +55,7 @@
validate: "{{ prometheus_daemon_dir }}/promtool check rules %s" validate: "{{ prometheus_daemon_dir }}/promtool check rules %s"
with_dict: '{{ prometheus_rule_files | default({}) }}' with_dict: '{{ prometheus_rule_files | default({}) }}'
notify: notify:
- reload prometheus - restart prometheus
- name: copy prometheus main config file from role's default, if necessary - name: copy prometheus main config file from role's default, if necessary
template: template:
@ -61,7 +64,7 @@
validate: "{{ prometheus_daemon_dir }}/promtool check config %s" validate: "{{ prometheus_daemon_dir }}/promtool check config %s"
when: prometheus_conf_main is not defined when: prometheus_conf_main is not defined
notify: notify:
- reload prometheus - restart prometheus
- name: copy prometheus main config file from playbook's, if any - name: copy prometheus main config file from playbook's, if any
template: template:
@ -70,7 +73,7 @@
validate: "{{ prometheus_daemon_dir }}/promtool check config %s" validate: "{{ prometheus_daemon_dir }}/promtool check config %s"
when: prometheus_conf_main is defined when: prometheus_conf_main is defined
notify: notify:
- reload prometheus - restart prometheus
- name: enable prometheus service - name: enable prometheus service
service: service: