ansible-ffibk/roles/service-prometheus/tasks/alertmanager.yml

77 lines
2 KiB
YAML
Raw Permalink Normal View History

2017-12-05 05:58:34 +01:00
---
# Install Prometheus alertmanager.
- name: set internal variables, part 1
set_fact:
alertmanager_present: yes
2017-12-05 05:58:34 +01:00
alertmanager_signature: "alertmanager-{{ alertmanager_version }}.linux-amd64"
- name: set internal variables, part 2
set_fact:
alertmanager_daemon_dir: "{{ prometheus_install_path }}/{{ alertmanager_signature }}"
- name: set download url
set_fact:
alertmanager_tarball_url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/{{ alertmanager_signature }}.tar.gz"
- name: download and uncompress alertmanager tarball
unarchive:
src: "{{ alertmanager_tarball_url }}"
dest: "{{ prometheus_install_path }}"
copy: no
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "go-w"
creates: "{{ alertmanager_daemon_dir }}"
- name: create alertmanager /usr/local/bin links
file:
src: "{{ alertmanager_daemon_dir }}/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
state: link
loop:
2017-12-05 05:58:34 +01:00
- "alertmanager"
- "amtool"
- name: mkdir for alertmanager data (silences.json for now)
file:
path: "{{ alertmanager_db_path }}"
2017-12-05 05:58:34 +01:00
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "u=rwx,g=rx,o="
- name: mkdir for amtool config
file:
path: "/etc/amtool"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "u=rwx,g=rx,o=rx"
- name: copy alertmanager systemd config
2017-12-05 05:58:34 +01:00
template:
src: "alertmanager.service.j2"
dest: "/lib/systemd/system/alertmanager.service"
notify:
- reload systemd
- restart alertmanager
2017-12-05 05:58:34 +01:00
- name: install amtool config file
copy:
src: "amtool.yml"
dest: "/etc/amtool/config.yml"
2017-12-05 05:58:34 +01:00
- name: install alertmanager config file
copy:
src: "alertmanager.yml"
dest: "{{ prometheus_config_path }}/alertmanager.yml"
notify:
- restart alertmanager
2017-12-05 05:58:34 +01:00
- name: enable alertmanager service
service:
2017-12-05 05:58:34 +01:00
name: alertmanager
enabled: yes
state: started