enhancement(alertmanager): add skip_install variable

This is similar to prometheus_skip_install variable and does what the
name says: when set, it won't try to re-download alertmanager binaries

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt 2023-03-16 12:35:26 +01:00
parent e06f9bbef1
commit 54e98d3a72
No known key found for this signature in database
GPG key ID: F3F92DA383FDDE09
5 changed files with 14 additions and 2 deletions

View file

@ -19,6 +19,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `alertmanager_version` | 0.21.0 | Alertmanager package version. Also accepts `latest` as parameter. |
| `alertmanager_skip_install` | false | Alertmanager installation tasks gets skipped when set to true. |
| `alertmanager_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `alertmanager` AND `amtool` binaries are stored on host on which ansible is ran. This overrides `alertmanager_version` parameter |
| `alertmanager_binary_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz` | URL of the alertmanager binaries .tar.gz file |
| `alertmanager_checksums_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt` | URL of the alertmanager checksums file |

View file

@ -4,6 +4,7 @@ alertmanager_binary_local_dir: ''
alertmanager_binary_url: "https://github.com/{{ _alertmanager_repo }}/releases/download/v{{ alertmanager_version }}/\
alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
alertmanager_checksums_url: "https://github.com/{{ _alertmanager_repo }}/releases/download/v{{ alertmanager_version }}/sha256sums.txt"
alertmanager_skip_install: false
alertmanager_config_dir: /etc/alertmanager
alertmanager_db_dir: /var/lib/alertmanager

View file

@ -11,6 +11,10 @@ argument_specs:
alertmanager_version:
description: "Alertmanager package version. Also accepts `latest` as parameter."
default: 0.21.0
alertmanager_skip_install:
description: "Alertmanager installation tasks gets skipped when set to true."
type: bool
default: false
alertmanager_binary_local_dir:
description:
- "Allows to use local packages instead of ones distributed on github."

View file

@ -27,7 +27,9 @@
- "{{ _alertmanager_amtool_config_dir }}"
- name: Get alertmanager binary
when: alertmanager_binary_local_dir | length == 0
when:
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install
block:
- name: Download alertmanager binary to local folder
@ -78,6 +80,8 @@
with_items:
- alertmanager
- amtool
when: alertmanager_binary_local_dir | length > 0
when:
- alertmanager_binary_local_dir | length > 0
- not alertmanager_skip_install
notify:
- restart alertmanager

View file

@ -29,10 +29,12 @@
when:
- alertmanager_version == "latest"
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install
- name: Get alertmanager binary checksum
when:
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install
block:
- name: "Get checksum list"
ansible.builtin.set_fact: