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

65 lines
1.7 KiB
YAML

---
# Install Prometheus alertmanager.
- name: set internal variables, part 1
set_fact:
alertmanager_present: yes
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
with_items:
- "alertmanager"
- "amtool"
- name: mkdir for alertmanager data (silences.json for now)
file:
path: "{{ item }}"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "u=rwx,g=rx,o="
with_items:
- "{{ alertmanager_db_path }}"
- name: copy alertmanager systemd config
template:
src: "alertmanager.service.j2"
dest: "/lib/systemd/system/alertmanager.service"
notify:
- reload systemd
- restart alertmanager
- name: install alertmanager config file
copy:
src: "alertmanager.yml"
dest: "{{ prometheus_config_path }}/alertmanager.yml"
notify:
- restart alertmanager
- name: enable alertmanager service
service:
name: alertmanager
enabled: yes
state: started