This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always install in /usr/local/bin & role cleanup (#28)
Port changes from other @cloudalchemy roles: - Remove blackbox_exporter_root_dir option and always install binary in /usr/local/bin - split tasks/main.yml into multiple files - add tags support - fix readme after previous release Create a new [minor] release.
- Loading branch information
1 parent
e886478
commit 602bc35
Showing
8 changed files
with
108 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: create systemd service unit | ||
template: | ||
src: blackbox_exporter.service.j2 | ||
dest: /etc/systemd/system/blackbox_exporter.service | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: | ||
- restart blackbox exporter | ||
|
||
- name: configure blackbox exporter | ||
template: | ||
src: blackbox_exporter.yml.j2 | ||
dest: /etc/blackbox_exporter.yml | ||
owner: blackbox-exp | ||
group: blackbox-exp | ||
mode: 0644 | ||
notify: | ||
- reload blackbox exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
- name: create blackbox_exporter system group | ||
group: | ||
name: blackbox-exp | ||
system: true | ||
state: present | ||
|
||
- name: create blackbox_exporter system user | ||
user: | ||
name: blackbox-exp | ||
system: true | ||
shell: "/sbin/nologin" | ||
group: blackbox-exp | ||
createhome: false | ||
|
||
- name: download blackbox exporter binary to local folder | ||
become: false | ||
unarchive: | ||
src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz" | ||
dest: "/tmp" | ||
remote_src: true | ||
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter" | ||
register: _download_binary | ||
until: _download_binary is succeeded | ||
retries: 5 | ||
delay: 2 | ||
delegate_to: localhost | ||
check_mode: false | ||
|
||
- name: propagate blackbox exporter binary | ||
copy: | ||
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter" | ||
dest: "/usr/local/bin/blackbox_exporter" | ||
mode: 0750 | ||
owner: blackbox-exp | ||
group: blackbox-exp | ||
notify: | ||
- restart blackbox exporter | ||
|
||
- name: Install libcap on Debian systems | ||
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 | ||
capabilities: | ||
path: '/usr/local/bin/blackbox_exporter' | ||
capability: cap_net_raw+ep | ||
state: present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,26 @@ | ||
--- | ||
- name: create blackbox_exporter system group | ||
group: | ||
name: blackbox-exp | ||
system: true | ||
state: present | ||
|
||
- name: create blackbox_exporter system user | ||
user: | ||
name: blackbox-exp | ||
system: true | ||
shell: "/sbin/nologin" | ||
group: blackbox-exp | ||
createhome: false | ||
|
||
- name: create blackbox_exporter directories | ||
file: | ||
path: "{{ blackbox_exporter_root_dir }}" | ||
state: directory | ||
owner: blackbox-exp | ||
group: blackbox-exp | ||
mode: 0755 | ||
|
||
- name: download blackbox exporter binary to local folder | ||
become: false | ||
unarchive: | ||
src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz" | ||
dest: "/tmp" | ||
remote_src: true | ||
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter" | ||
register: _download_binary | ||
until: _download_binary is succeeded | ||
retries: 5 | ||
delay: 2 | ||
delegate_to: localhost | ||
check_mode: false | ||
|
||
- name: propagate blackbox exporter binary | ||
copy: | ||
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter" | ||
dest: "{{ blackbox_exporter_root_dir }}/blackbox_exporter" | ||
mode: 0750 | ||
owner: blackbox-exp | ||
group: blackbox-exp | ||
notify: | ||
- restart blackbox exporter | ||
|
||
- name: Install libcap on Debian systems | ||
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 | ||
capabilities: | ||
path: '{{ blackbox_exporter_root_dir }}/blackbox_exporter' | ||
capability: cap_net_raw+ep | ||
state: present | ||
|
||
- name: create systemd service unit | ||
template: | ||
src: blackbox_exporter.service.j2 | ||
dest: /etc/systemd/system/blackbox_exporter.service | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: | ||
- restart blackbox exporter | ||
|
||
- name: configure blackbox exporter | ||
template: | ||
src: blackbox_exporter.yml.j2 | ||
dest: /etc/blackbox_exporter.yml | ||
owner: blackbox-exp | ||
group: blackbox-exp | ||
mode: 0644 | ||
notify: | ||
- reload blackbox exporter | ||
|
||
- name: ensure blackbox_exporter service is enabled | ||
- include: preflight.yml | ||
tags: | ||
- blackbox_exporter_install | ||
- blackbox_exporter_configure | ||
- blackbox_exporter_run | ||
|
||
- include: install.yml | ||
become: true | ||
tags: | ||
- blackbox_exporter_install | ||
|
||
- include: configure.yml | ||
become: true | ||
tags: | ||
- blackbox_exporter_configure | ||
|
||
- name: ensure blackbox_exporter service is started and enabled | ||
become: true | ||
systemd: | ||
daemon_reload: true | ||
name: blackbox_exporter | ||
state: started | ||
enabled: true | ||
tags: | ||
- blackbox_exporter_run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters