From 01cda8792213340fdedcd364dedb2a73564d27f2 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Fri, 13 Nov 2020 17:47:31 -0500 Subject: Remove systemd support. Add alertmanager. Remove old template --- tasks/main.yml | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'tasks/main.yml') diff --git a/tasks/main.yml b/tasks/main.yml index cb2645a..19ca131 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,15 +22,21 @@ dest: "{{prometheus_home_dir}}/prometheus-{{prometheus_version}}.tgz" mode: '0600' owner: "{{prometheus_user}}" - checksum: 'sha256:{{prometheus_checksum}}' + checksum: 'sha256:{{prometheus_checksum}}' # There's a bug in become_user that doesn't set permissions on the temp directory # which is asinine when my user has sudo persmissions. - name: Extract Prometheus shell: | + #!/bin/sh + set -e if ! [ -e "{{prometheus_home_dir}}/{{prometheus_extract_dir}}" ] ; then su - '{{prometheus_user}}' -c 'tar xzf prometheus-{{prometheus_version}}.tgz' + exit 50 fi - changed_when: false + register: res + changed_when: res is defined and res.rc == 50 + ignore_errors: true + notify: Restart Prometheus - name: Link prometheus directory file: state: link @@ -45,15 +51,38 @@ force: yes loop: - prometheus.yml -- name: Write prometheus template - template: - src: '{{prometheus_template_source}}' +- name: Write prometheus configuration file + copy: + content: '{{prometheus_config | to_nice_yaml}}' dest: '{{prometheus_home_dir}}/conf/prometheus.yml' owner: '{{prometheus_user}}' mode: '0600' -- name: Run Runit Specific tasks - include_tasks: systemd.yml - when: ansible_facts['distribution'].lower() == "ubuntu" or ansible_facts['distribution'].lower() == "centos" -- name: Run Runit Specific tasks - include_tasks: runit.yml - when: ansible_facts['distribution'].lower() == "void" or ansible_facts['distribution'].lower() == "alpine" + notify: Restart prometheus + tags: + - configuration +- name: Create Runit Directory + file: + state: directory + dest: /etc/sv/prometheus + owner: root + mode: '0755' +- name: Write runit service + template: + src: prometheus.runit + dest: /etc/sv/prometheus/run + owner: root + mode: '0755' +- name: Enable Runit service + file: + state: link + src: /etc/sv/prometheus + dest: /var/service/prometheus +- name: Include Aertmanager tasks + include_tasks: + file: alertmanager.yml + apply: + tags: + - alertmanager + tags: + - alertmanager + when: alertmanager -- cgit v1.2.3