commit 028abbb323551de18df69cb97178fafb1ba82dbd
parent 8c51cdf37faafecb6568ce5e9e4d2f50e64a1b0a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 21:13:31 +0100
parent 8c51cdf37faafecb6568ce5e9e4d2f50e64a1b0a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 21:13:31 +0100
roles/prometheus: split tasks into multiple files
8 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml @@ -0,0 +1,17 @@ +--- + +- name: "[OpenRC] Restart service: prometheus (to deploy config changes)" + service: + name: prometheus + state: restarted + when: + - ansible_service_mgr == "openrc" + listen: "Restart prometheus" + +- name: "[systemd] Restart service: prometheus (to deploy config changes)" + systemd: + name: prometheus + state: restarted + when: + - ansible_service_mgr == "systemd" + listen: "Restart prometheus"
diff --git a/roles/prometheus/meta/main.y\ml b/roles/prometheus/meta/main.y\ml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: nginx
diff --git a/roles/prometheus/tasks/configure.yml b/roles/prometheus/tasks/configure.yml @@ -4,3 +4,4 @@ copy: content: "#\n# !!! This file is managed by Ansible !!!\n#\n\n{{ services.prometheus.config | to_nice_yaml }}" dest: /etc/prometheus/prometheus.yml + notify: "Restart prometheus"+ \ No newline at end of file
diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml @@ -4,7 +4,6 @@ apk: name: prometheus state: present - update_cache: yes when: - ansible_distribution == "Alpine" @@ -12,6 +11,5 @@ pacman: name: prometheus state: present - update_cache: yes when: - ansible_distribution == "Archlinux"
diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml @@ -32,7 +32,4 @@ - services.prometheus.enable is defined - services.prometheus.enable is false - - - - +- meta: flush_handlers
diff --git a/roles/prometheus/tasks/nginx.yml b/roles/prometheus/tasks/nginx.yml @@ -7,17 +7,4 @@ mode: 0644 owner: nginx group: nginx - -- name: "[OpenRC] Restart service: nginx" - service: - name: nginx - state: restarted - when: - - ansible_service_mgr == "openrc" - -- name: "[systemd] Restart service: nginx" - systemd: - name: nginx - state: restarted - when: - - ansible_service_mgr == "systemd"- \ No newline at end of file + notify: "Restart nginx"+ \ No newline at end of file
diff --git a/roles/prometheus/tasks/remove.yml b/roles/prometheus/tasks/remove.yml @@ -35,5 +35,10 @@ path: "{{item}}" state: absent with_items: - - /etc/nginx/conf.d/prometheus.conf - - /etc/prometheus- \ No newline at end of file + - /etc/prometheus + +- name: "Delete nginx vhost for: prometheus" + file: + path: /etc/nginx/conf.d/prometheus.conf + state: absent + notify: "Restart nginx"
diff --git a/roles/prometheus/tasks/start.yml b/roles/prometheus/tasks/start.yml @@ -1,17 +1,17 @@ --- -- name: "[OpenRC] Restart and enable service: prometheus" +- name: "[OpenRC] Enable and start service: prometheus" service: name: prometheus enabled: yes - state: restarted + state: started when: - ansible_service_mgr == "openrc" -- name: "[systemd] Restart and enable service: prometheus" +- name: "[systemd] Enable and start service: prometheus" systemd: name: prometheus enabled: yes - state: restarted + state: started when: - ansible_service_mgr == "systemd"