ansible-collection-prometheus/roles/alertmanager/tasks/install.yml
gardar 2529617e41
fix(lint): fix all linter exceptions and remove exception rules
Signed-off-by: gardar <gardar@users.noreply.github.com>
2022-11-25 15:39:18 +00:00

84 lines
2.6 KiB
YAML

---
- name: Create alertmanager system group
ansible.builtin.group:
name: alertmanager
system: true
state: present
- name: Create alertmanager system user
ansible.builtin.user:
name: alertmanager
system: true
shell: "/usr/sbin/nologin"
ansible.builtin.group: alertmanager
createhome: false
- name: Create alertmanager directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: alertmanager
ansible.builtin.group: alertmanager
mode: 0755
with_items:
- "{{ alertmanager_config_dir }}"
- "{{ alertmanager_config_dir }}/templates"
- "{{ alertmanager_db_dir }}"
- "{{ _alertmanager_amtool_config_dir }}"
- name: Get alertmanager binary
when: alertmanager_binary_local_dir | length == 0
block:
- name: Download alertmanager binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/
alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ __alertmanager_checksum }}"
mode: 0644
register: _download_archive
until: _download_archive is succeeded
retries: 5
delay: 2
# run_once: true # <-- this can't be set due to multi-arch support
delegate_to: localhost
check_mode: false
- name: Unpack alertmanager binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp"
mode: 0755
creates: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}/alertmanager"
delegate_to: localhost
check_mode: false
- name: Propagate official alertmanager and amtool binaries
ansible.builtin.copy:
src: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}/{{ item }}"
dest: "{{ _alertmanager_binary_install_dir }}/{{ item }}"
mode: 0755
owner: root
ansible.builtin.group: root
with_items:
- alertmanager
- amtool
notify:
- restart alertmanager
- name: Propagate locally distributed alertmanager and amtool binaries
ansible.builtin.copy:
src: "{{ alertmanager_binary_local_dir }}/{{ item }}"
dest: "{{ _alertmanager_binary_install_dir }}/{{ item }}"
mode: 0755
owner: root
ansible.builtin.group: root
with_items:
- alertmanager
- amtool
when: alertmanager_binary_local_dir | length > 0
notify:
- restart alertmanager