Skip to content

Commit

Permalink
Alertmanager: add skip_install variable
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
chrisbra committed Mar 16, 2023
1 parent 045d154 commit cd7c7cc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions roles/alertmanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions roles/alertmanager/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions roles/alertmanager/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 6 additions & 2 deletions roles/alertmanager/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions roles/alertmanager/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cd7c7cc

Please sign in to comment.