mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-29 23:30:18 +00:00
8c52c4df29
Signed-off-by: Thomas Venieris <thomas.venieris@gmail.com> Co-authored-by: Ben Kochie <superq@gmail.com>
90 lines
3 KiB
YAML
90 lines
3 KiB
YAML
---
|
|
- name: Create blackbox_exporter system group
|
|
ansible.builtin.group:
|
|
name: "{{ blackbox_exporter_group }}"
|
|
system: true
|
|
state: present
|
|
when: blackbox_exporter_group != 'root'
|
|
|
|
- name: Create blackbox_exporter system user
|
|
ansible.builtin.user:
|
|
name: "{{ blackbox_exporter_user }}"
|
|
system: true
|
|
shell: "/usr/sbin/nologin"
|
|
group: "{{ blackbox_exporter_group }}"
|
|
createhome: false
|
|
when: blackbox_exporter_user != 'root'
|
|
|
|
- name: Get binary
|
|
when:
|
|
- blackbox_exporter_binary_local_dir | length == 0
|
|
- not blackbox_exporter_skip_install
|
|
block:
|
|
|
|
- name: Download blackbox_exporter binary to local folder
|
|
become: false
|
|
ansible.builtin.get_url:
|
|
url: "{{ blackbox_exporter_binary_url }}"
|
|
dest: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
checksum: "sha256:{{ __blackbox_exporter_checksum }}"
|
|
mode: '0644'
|
|
register: _download_binary
|
|
until: _download_binary is succeeded
|
|
retries: 5
|
|
delay: 2
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Unpack blackbox_exporter binary
|
|
become: false
|
|
ansible.builtin.unarchive:
|
|
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
|
dest: "/tmp"
|
|
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch }}/blackbox_exporter"
|
|
delegate_to: localhost
|
|
check_mode: false
|
|
|
|
- name: Propagate blackbox_exporter binaries
|
|
ansible.builtin.copy:
|
|
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch }}/blackbox_exporter"
|
|
dest: "{{ blackbox_exporter_binary_install_dir }}/blackbox_exporter"
|
|
mode: 0755
|
|
owner: root
|
|
group: root
|
|
notify: restart blackbox_exporter
|
|
when: not ansible_check_mode
|
|
|
|
- name: Propagate locally distributed blackbox_exporter binary
|
|
ansible.builtin.copy:
|
|
src: "{{ blackbox_exporter_binary_local_dir }}/blackbox_exporter"
|
|
dest: "{{ blackbox_exporter_binary_install_dir }}/blackbox_exporter"
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
when:
|
|
- blackbox_exporter_binary_local_dir | length > 0
|
|
- not blackbox_exporter_skip_install
|
|
notify: restart blackbox_exporter
|
|
|
|
- name: Install libcap on Debian systems
|
|
ansible.builtin.package:
|
|
name: "libcap2-bin"
|
|
state: present
|
|
register: _download_packages
|
|
until: _download_packages is succeeded
|
|
retries: 5
|
|
delay: 2
|
|
when: ansible_os_family | lower == "debian"
|
|
|
|
- name: Ensure blackbox exporter binary has cap_net_raw capability
|
|
community.general.capabilities:
|
|
path: '/usr/local/bin/blackbox_exporter'
|
|
capability: cap_net_raw+ep
|
|
state: present
|
|
when: not ansible_check_mode
|
|
changed_when: "'molecule-idempotence-notest' not in ansible_skip_tags"
|
|
|
|
- name: Check Debug Message
|
|
ansible.builtin.debug:
|
|
msg: "The capabilities module is skipped during check mode, as the file may not exist, causing execution to fail."
|
|
when: ansible_check_mode
|