-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make binary installs consistent
Update the blackbox_exporter and snmp_exporter installs to be consistent with other exporter package installs. Signed-off-by: SuperQ <superq@gmail.com>
- Loading branch information
Showing
12 changed files
with
231 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
provisioner: | ||
inventory: | ||
group_vars: | ||
all: | ||
blackbox_exporter_version: latest |
37 changes: 37 additions & 0 deletions
37
roles/blackbox_exporter/molecule/latest/tests/test_latest.py
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,37 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra.utils.ansible_runner | ||
import pytest | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') | ||
|
||
|
||
@pytest.mark.parametrize("files", [ | ||
"/etc/systemd/system/blackbox_exporter.service", | ||
"/usr/local/bin/blackbox_exporter" | ||
]) | ||
def test_files(host, files): | ||
f = host.file(files) | ||
assert f.exists | ||
assert f.is_file | ||
|
||
|
||
def test_service(host): | ||
s = host.service("blackbox_exporter") | ||
try: | ||
assert s.is_running | ||
except AssertionError: | ||
# Capture service logs | ||
journal_output = host.run('journalctl -u blackbox_exporter --since "1 hour ago"') | ||
print("\n==== journalctl -u blackbox_exporter Output ====\n") | ||
print(journal_output) | ||
print("\n============================================\n") | ||
raise # Re-raise the original assertion error | ||
|
||
|
||
def test_socket(host): | ||
s = host.socket("tcp://0.0.0.0:9100") | ||
assert s.is_listening |
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
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 |
---|---|---|
@@ -1,9 +1,31 @@ | ||
--- | ||
- name: "Get checksum for snmp exporter" | ||
- name: Discover latest version | ||
ansible.builtin.set_fact: | ||
snmp_exporter_checksum: "{{ item.split(' ')[0] }}" | ||
with_items: | ||
- "{{ lookup('url', snmp_exporter_checksums_url, headers=_github_api_headers, wantlist=True) | list }}" | ||
snmp_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/prometheus/snmp_exporter/releases/latest', headers=_github_api_headers, | ||
split_lines=False) | from_json).get('tag_name') | replace('v', '') }}" | ||
run_once: true | ||
until: snmp_exporter_version is version('0.0.0', '>=') | ||
retries: 10 | ||
when: | ||
- "('linux-' + (go_arch_map[ansible_architecture] | default(ansible_architecture)) + '.tar.gz') in item" | ||
- snmp_exporter_version == "latest" | ||
- snmp_exporter_binary_local_dir | length == 0 | ||
- not snmp_exporter_skip_install | ||
|
||
- name: Get snmp_exporter binary checksum | ||
when: | ||
- snmp_exporter_binary_local_dir | length == 0 | ||
- not snmp_exporter_skip_install | ||
block: | ||
- name: Get checksum list from github | ||
ansible.builtin.set_fact: | ||
__snmp_exporter_checksums: "{{ lookup('url', snmp_exporter_checksums_url, headers=_github_api_headers, wantlist=True) | list }}" | ||
run_once: true | ||
until: __snmp_exporter_checksums is search('linux-' + go_arch + '.tar.gz') | ||
retries: 10 | ||
|
||
- name: "Get checksum for {{ go_arch }}" | ||
ansible.builtin.set_fact: | ||
__snmp_exporter_checksum: "{{ item.split(' ')[0] }}" | ||
with_items: "{{ __snmp_exporter_checksums }}" | ||
when: | ||
- "('linux-' + go_arch + '.tar.gz') in item" |
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