This role installs amtool
(from alertmanager) on the Ansible
control host (note: this is the machine that you run your playbooks on, not the host
which you are provisioning with Ansible). The purpose of this role is to make amtool
available on the control host in order to create and expire silences.
Ansible >= 2.10, and a control host which is either running a Debian-flavor of Linux, or macOS.
See the defaults/main.yml
file for full documentation on required
and optional role variables.
After the role installs amtool
, it will set the amtool_exe
fact to the path of the
installed executable. This fact can be used to call amtool
from subsequent command
tasks in your playbooks. Note that such tasks must be delegated to localhost
.
---
- name: Create alert silences for all hosts
hosts: "all"
gather_facts: false
vars:
alertmanager_url: "https://example.com/alertmanager"
comment: "Added by Ansible"
expiration_timeout: "4h"
roles:
- role: ableton.amtool
run_once: true
tasks:
- name: Create silences for example alerts
delegate_to: localhost
command: "{{ amtool_exe }} \
--alertmanager.url={{ alertmanager_url }} \
silence add \
--comment='{{ comment }}' \
--duration={{ expiration_timeout }} \
alertname={{ alert_item }}"
loop_control:
loop_var: alert_item
with_items:
- "example_alert_one"
- "example_alert_two"
MIT
This project is maintained by the following GitHub users: