mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-25 21:30:24 +00:00
Merge pull request #197 from gardar/molecule-testinfra
skip_changelog: molecule and testinfra cleanup
This commit is contained in:
commit
255dabc9aa
99 changed files with 793 additions and 659 deletions
|
@ -78,3 +78,6 @@ platforms:
|
|||
command: /lib/systemd/systemd
|
||||
verifier:
|
||||
name: testinfra
|
||||
provisioner:
|
||||
playbooks:
|
||||
converge: "${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/converge.yml"
|
||||
|
|
8
.config/molecule/converge.yml
Normal file
8
.config/molecule/converge.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: "Run role"
|
||||
ansible.builtin.include_role:
|
||||
name: "prometheus.prometheus.{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
|
|
@ -1,35 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_binary_local_dir: '/tmp/alertmanager-linux-amd64'
|
||||
alertmanager_config_dir: /opt/am/etc
|
||||
alertmanager_db_dir: /opt/am/lib
|
||||
alertmanager_web_listen_address: '127.0.0.1:9093'
|
||||
alertmanager_web_external_url: 'http://localhost:9093/alertmanager'
|
||||
alertmanager_resolve_timeout: 10m
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
api_url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
||||
routes:
|
||||
- match_re:
|
||||
service: ^(foo1|foo2|baz)$
|
||||
receiver: slack
|
||||
alertmanager_mesh:
|
||||
listen-address: "127.0.0.1:6783"
|
||||
peers:
|
||||
- "127.0.0.1:6783"
|
||||
- "alertmanager.demo.do.prometheus.io:6783"
|
|
@ -1 +1,34 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
alertmanager_binary_local_dir: '/tmp/alertmanager-linux-amd64'
|
||||
alertmanager_config_dir: /opt/am/etc
|
||||
alertmanager_db_dir: /opt/am/lib
|
||||
alertmanager_web_listen_address: '127.0.0.1:9093'
|
||||
alertmanager_web_external_url: 'http://localhost:9093/alertmanager'
|
||||
alertmanager_resolve_timeout: 10m
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
api_url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
||||
routes:
|
||||
- match_re:
|
||||
service: ^(foo1|foo2|baz)$$
|
||||
receiver: slack
|
||||
alertmanager_mesh:
|
||||
listen-address: "127.0.0.1:6783"
|
||||
peers:
|
||||
- "127.0.0.1:6783"
|
||||
- "alertmanager.demo.do.prometheus.io:6783"
|
||||
version: 0.19.0
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run localhost preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
# Version needs to be specified here as molecule doesn't have access to ansible_version at this stage
|
||||
version: 0.19.0
|
||||
tasks:
|
||||
- name: Download alertmanager binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ version }}/alertmanager-{{ version }}.linux-amd64.tar.gz"
|
||||
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ version\
|
||||
\ }}/alertmanager-{{ version }}.linux-amd64.tar.gz"
|
||||
dest: "/tmp/alertmanager-{{ version }}.linux-amd64.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_archive
|
||||
|
|
|
@ -34,8 +34,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("alertmanager")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u alertmanager --since "1 hour ago"')
|
||||
print("\n==== journalctl -u alertmanager Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
@pytest.mark.parametrize("sockets", [
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
|
@ -1 +1,17 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
||||
|
|
|
@ -34,8 +34,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("alertmanager")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u alertmanager --since "1 hour ago"')
|
||||
print("\n==== journalctl -u alertmanager Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_version: latest
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
|
@ -1 +1,18 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
alertmanager_version: latest
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
||||
- name: slack
|
||||
slack_configs:
|
||||
- send_resolved: true
|
||||
channel: '#alerts'
|
||||
alertmanager_route:
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
group_wait: 30s
|
||||
group_interval: 5m
|
||||
repeat_interval: 3h
|
||||
receiver: slack
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("alertmanager")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u alertmanager --since "1 hour ago"')
|
||||
print("\n==== journalctl -u alertmanager Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
group: alertmanager
|
||||
mode: 0644
|
||||
validate: "{{ _alertmanager_binary_install_dir }}/amtool check-config %s"
|
||||
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
||||
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
|
||||
notify:
|
||||
- restart alertmanager
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.blackbox_exporter
|
||||
vars:
|
||||
blackbox_exporter_web_listen_address: "127.0.0.1:9000"
|
||||
blackbox_exporter_cli_flags:
|
||||
log.level: "warn"
|
||||
blackbox_exporter_configuration_modules:
|
||||
tcp_connect:
|
||||
prober: tcp
|
||||
timeout: 5s
|
|
@ -1 +1,12 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
blackbox_exporter_web_listen_address: "127.0.0.1:9000"
|
||||
blackbox_exporter_cli_flags:
|
||||
log.level: "warn"
|
||||
blackbox_exporter_configuration_modules:
|
||||
tcp_connect:
|
||||
prober: tcp
|
||||
timeout: 5s
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("blackbox_exporter")
|
||||
assert s.is_running
|
||||
# assert s.is_enabled
|
||||
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):
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.blackbox_exporter
|
|
@ -1 +1,5 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all: {}
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("blackbox_exporter")
|
||||
assert s.is_running
|
||||
# assert s.is_enabled
|
||||
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):
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.chrony_exporter
|
||||
pre_tasks:
|
||||
- name: Create chrony_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ chrony_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ chrony_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ chrony_exporter_tls_server_config.key_file }}"
|
||||
vars:
|
||||
chrony_exporter_binary_local_dir: "/tmp/chrony_exporter-linux-amd64"
|
||||
chrony_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
chrony_exporter_enabled_collectors:
|
||||
- sources
|
||||
chrony_exporter_disabled_collectors:
|
||||
- tracking
|
||||
|
||||
chrony_exporter_tls_server_config:
|
||||
cert_file: /etc/chrony_exporter/tls.cert
|
||||
key_file: /etc/chrony_exporter/tls.key
|
||||
chrony_exporter_http_server_config:
|
||||
http2: true
|
||||
chrony_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
|
@ -1 +1,21 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
chrony_exporter_binary_local_dir: "/tmp/chrony_exporter-linux-amd64"
|
||||
chrony_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
chrony_exporter_enabled_collectors:
|
||||
- sources
|
||||
chrony_exporter_disabled_collectors:
|
||||
- tracking
|
||||
|
||||
chrony_exporter_tls_server_config:
|
||||
cert_file: /etc/chrony_exporter/tls.cert
|
||||
key_file: /etc/chrony_exporter/tls.key
|
||||
chrony_exporter_http_server_config:
|
||||
http2: true
|
||||
chrony_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
||||
go_arch: amd64
|
||||
chrony_exporter_version: 0.6.0
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
chrony_exporter_version: 0.6.0
|
||||
tasks:
|
||||
- name: Download chrony_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/superq/chrony_exporter/releases/download/v{{ chrony_exporter_version }}/\
|
||||
chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/superq/chrony_exporter/releases/download/v{{ chrony_exporter_version\
|
||||
\ }}/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
@ -22,9 +20,11 @@
|
|||
- name: Unpack chrony_exporter binary
|
||||
become: false
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
src: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
creates: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}/chrony_exporter"
|
||||
creates: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}/chrony_exporter"
|
||||
check_mode: false
|
||||
|
||||
- name: Link to chrony_exporter binaries directory
|
||||
|
@ -54,3 +54,26 @@
|
|||
csr_path: "/tmp/tls.csr"
|
||||
privatekey_path: "/tmp/tls.key"
|
||||
provider: selfsigned
|
||||
|
||||
- name: Run target preparation
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: Create chrony_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ chrony_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ chrony_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ chrony_exporter_tls_server_config.key_file }}"
|
||||
|
|
|
@ -20,7 +20,15 @@ def test_directories(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("chrony_exporter")
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u chrony_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u chrony_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.chrony_exporter
|
||||
vars:
|
||||
chrony_exporter_web_listen_address: "127.0.0.1:9123"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
chrony_exporter_web_listen_address: "127.0.0.1:9123"
|
||||
|
|
|
@ -53,8 +53,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("chrony_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u chrony_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u chrony_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.chrony_exporter
|
||||
vars:
|
||||
chrony_exporter_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
chrony_exporter_version: latest
|
||||
|
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("chrony_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u chrony_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u chrony_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.mysqld_exporter
|
||||
pre_tasks:
|
||||
- name: Create mysqld_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ mysqld_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ mysqld_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ mysqld_exporter_tls_server_config.key_file }}"
|
||||
vars:
|
||||
mysqld_exporter_binary_local_dir: "/tmp/mysqld_exporter-linux-amd64"
|
||||
mysqld_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
mysqld_exporter_enabled_collectors:
|
||||
- slave_hosts
|
||||
mysqld_exporter_disabled_collectors:
|
||||
- global_variables
|
||||
|
||||
mysqld_exporter_tls_server_config:
|
||||
cert_file: /etc/mysqld_exporter/tls.cert
|
||||
key_file: /etc/mysqld_exporter/tls.key
|
||||
mysqld_exporter_http_server_config:
|
||||
http2: true
|
||||
mysqld_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
|
@ -1 +1,21 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
mysqld_exporter_binary_local_dir: "/tmp/mysqld_exporter-linux-amd64"
|
||||
mysqld_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
mysqld_exporter_enabled_collectors:
|
||||
- slave_hosts
|
||||
mysqld_exporter_disabled_collectors:
|
||||
- global_variables
|
||||
|
||||
mysqld_exporter_tls_server_config:
|
||||
cert_file: /etc/mysqld_exporter/tls.cert
|
||||
key_file: /etc/mysqld_exporter/tls.key
|
||||
mysqld_exporter_http_server_config:
|
||||
http2: true
|
||||
mysqld_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
||||
go_arch: amd64
|
||||
mysqld_exporter_version: 0.13.0
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
mysqld_exporter_version: 0.13.0
|
||||
tasks:
|
||||
- name: Download mysqld_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/mysqld_exporter/releases/download/v{{ mysqld_exporter_version }}/\
|
||||
mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/prometheus/mysqld_exporter/releases/download/v{{\
|
||||
\ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version\
|
||||
\ }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
@ -22,9 +21,11 @@
|
|||
- name: Unpack mysqld_exporter binary
|
||||
become: false
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
src: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
creates: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}/mysqld_exporter"
|
||||
creates: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}/mysqld_exporter"
|
||||
check_mode: false
|
||||
|
||||
- name: Link to mysqld_exporter binaries directory
|
||||
|
@ -54,3 +55,26 @@
|
|||
csr_path: "/tmp/tls.csr"
|
||||
privatekey_path: "/tmp/tls.key"
|
||||
provider: selfsigned
|
||||
|
||||
- name: Run target preparation
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: Create mysqld_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ mysqld_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ mysqld_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ mysqld_exporter_tls_server_config.key_file }}"
|
||||
|
|
|
@ -10,8 +10,15 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("mysqld_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u mysqld_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u mysqld_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.mysqld_exporter
|
||||
vars:
|
||||
mysqld_exporter_web_listen_address: "127.0.0.1:9104"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
mysqld_exporter_web_listen_address: "127.0.0.1:9104"
|
||||
|
|
|
@ -53,8 +53,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("mysqld_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u mysqld_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u mysqld_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.mysqld_exporter
|
||||
vars:
|
||||
mysqld_exporter_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
mysqld_exporter_version: latest
|
||||
|
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("mysqld_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u mysqld_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u mysqld_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
owner: root
|
||||
group: '{{ mysqld_exporter_system_group }}'
|
||||
mode: '0640'
|
||||
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
||||
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
|
||||
notify: restart mysqld_exporter
|
||||
|
||||
- name: Configure mysqld_exporter web config
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.node_exporter
|
||||
pre_tasks:
|
||||
- name: Create node_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ node_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ node_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ node_exporter_tls_server_config.key_file }}"
|
||||
vars:
|
||||
node_exporter_binary_local_dir: "/tmp/node_exporter-linux-amd64"
|
||||
node_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
node_exporter_textfile_dir: ""
|
||||
node_exporter_enabled_collectors:
|
||||
- entropy
|
||||
node_exporter_disabled_collectors:
|
||||
- diskstats
|
||||
|
||||
node_exporter_tls_server_config:
|
||||
cert_file: /etc/node_exporter/tls.cert
|
||||
key_file: /etc/node_exporter/tls.key
|
||||
node_exporter_http_server_config:
|
||||
http2: true
|
||||
node_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
|
@ -1 +1,22 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
node_exporter_binary_local_dir: "/tmp/node_exporter-linux-amd64"
|
||||
node_exporter_web_listen_address: "127.0.0.1:8080"
|
||||
node_exporter_textfile_dir: ""
|
||||
node_exporter_enabled_collectors:
|
||||
- entropy
|
||||
node_exporter_disabled_collectors:
|
||||
- diskstats
|
||||
|
||||
node_exporter_tls_server_config:
|
||||
cert_file: /etc/node_exporter/tls.cert
|
||||
key_file: /etc/node_exporter/tls.key
|
||||
node_exporter_http_server_config:
|
||||
http2: true
|
||||
node_exporter_basic_auth_users:
|
||||
randomuser: examplepassword
|
||||
go_arch: amd64
|
||||
node_exporter_version: 1.0.0
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
node_exporter_version: 1.0.0
|
||||
tasks:
|
||||
- name: Download node_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/\
|
||||
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{\
|
||||
\ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{\
|
||||
\ go_arch }}.tar.gz"
|
||||
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
|
@ -24,7 +22,8 @@
|
|||
ansible.builtin.unarchive:
|
||||
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
|
||||
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}/node_exporter"
|
||||
check_mode: false
|
||||
|
||||
- name: Link to node_exporter binaries directory
|
||||
|
@ -54,3 +53,26 @@
|
|||
csr_path: "/tmp/tls.csr"
|
||||
privatekey_path: "/tmp/tls.key"
|
||||
provider: selfsigned
|
||||
|
||||
- name: Run target preparation
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: Create node_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ node_exporter_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ node_exporter_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ node_exporter_tls_server_config.key_file }}"
|
||||
|
|
|
@ -19,8 +19,15 @@ def test_directories(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("node_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u node_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u node_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.node_exporter
|
||||
vars:
|
||||
node_exporter_web_listen_address: "127.0.0.1:9100"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
node_exporter_web_listen_address: "127.0.0.1:9100"
|
||||
|
|
|
@ -53,8 +53,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("node_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u node_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u node_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.node_exporter
|
||||
vars:
|
||||
node_exporter_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
node_exporter_version: latest
|
||||
|
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("node_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u node_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u node_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.prometheus
|
||||
vars:
|
||||
prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64'
|
||||
prometheus_config_dir: /opt/prom/etc
|
||||
prometheus_db_dir: /opt/prom/lib
|
||||
prometheus_web_listen_address: "127.0.0.1:9090"
|
||||
prometheus_web_external_url: "http://127.0.0.1:9090/prometheus"
|
||||
prometheus_read_only_dirs:
|
||||
- /etc
|
||||
prometheus_storage_retention: "60d"
|
||||
prometheus_storage_retention_size: "1GB"
|
||||
prometheus_config_flags_extra:
|
||||
alertmanager.timeout: 10s
|
||||
web.enable-admin-api:
|
||||
enable-feature:
|
||||
- promql-at-modifier
|
||||
- remote-write-receiver
|
||||
prometheus_alertmanager_config:
|
||||
- scheme: https
|
||||
path_prefix: /alertmanager
|
||||
basic_auth:
|
||||
username: user
|
||||
password: pass
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:9090"]
|
||||
proxy_url: "127.0.0.2"
|
||||
prometheus_alert_relabel_configs:
|
||||
- action: labeldrop
|
||||
regex: replica
|
||||
prometheus_global:
|
||||
scrape_interval: 3s
|
||||
scrape_timeout: 2s
|
||||
evaluation_interval: 10s
|
||||
prometheus_remote_write:
|
||||
- url: http://influx.example.org:8086/api/v1/prom/write?db=test
|
||||
basic_auth:
|
||||
username: prometheus
|
||||
password: SuperSecret
|
||||
prometheus_remote_read:
|
||||
- url: http://influx.example.org:8086/api/v1/prom/read?db=demo
|
||||
prometheus_external_labels:
|
||||
environment: "alternative"
|
||||
prometheus_targets:
|
||||
node:
|
||||
- targets:
|
||||
- node.demo.do.prometheus.io
|
||||
- influx.example.org:9100
|
||||
labels:
|
||||
env: demo
|
||||
docker:
|
||||
- targets:
|
||||
- demo.do.prometheus.io:8080
|
||||
- influx.example.org:8080
|
||||
labels:
|
||||
env: demo
|
||||
prometheus_scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
metrics_path: "{{ prometheus_metrics_path }}"
|
||||
static_configs:
|
||||
- targets:
|
||||
- "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090"
|
||||
- job_name: "node"
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/node.yml"
|
||||
- job_name: "docker"
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/docker.yml"
|
||||
- job_name: 'blackbox'
|
||||
metrics_path: /probe
|
||||
params:
|
||||
module: [http_2xx]
|
||||
static_configs:
|
||||
- targets:
|
||||
- http://node.demo.do.prometheus.io
|
||||
- http://influx.example.org:9100
|
||||
relabel_configs:
|
||||
- source_labels: [__address__]
|
||||
target_label: __param_target
|
||||
- source_labels: [__param_target]
|
||||
target_label: instance
|
||||
- target_label: __address__
|
||||
replacement: 127.0.0.1:9115 # Blackbox exporter.
|
|
@ -1 +1,89 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64'
|
||||
prometheus_config_dir: /opt/prom/etc
|
||||
prometheus_db_dir: /opt/prom/lib
|
||||
prometheus_web_listen_address: "127.0.0.1:9090"
|
||||
prometheus_web_external_url: "http://127.0.0.1:9090/prometheus"
|
||||
prometheus_read_only_dirs:
|
||||
- /etc
|
||||
prometheus_storage_retention: "60d"
|
||||
prometheus_storage_retention_size: "1GB"
|
||||
prometheus_config_flags_extra:
|
||||
alertmanager.timeout: 10s
|
||||
web.enable-admin-api:
|
||||
enable-feature:
|
||||
- promql-at-modifier
|
||||
- remote-write-receiver
|
||||
prometheus_alertmanager_config:
|
||||
- scheme: https
|
||||
path_prefix: /alertmanager
|
||||
basic_auth:
|
||||
username: user
|
||||
password: pass
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:9090"]
|
||||
proxy_url: "127.0.0.2"
|
||||
prometheus_alert_relabel_configs:
|
||||
- action: labeldrop
|
||||
regex: replica
|
||||
prometheus_global:
|
||||
scrape_interval: 3s
|
||||
scrape_timeout: 2s
|
||||
evaluation_interval: 10s
|
||||
prometheus_remote_write:
|
||||
- url: http://influx.example.org:8086/api/v1/prom/write?db=test
|
||||
basic_auth:
|
||||
username: prometheus
|
||||
password: SuperSecret
|
||||
prometheus_remote_read:
|
||||
- url: http://influx.example.org:8086/api/v1/prom/read?db=demo
|
||||
prometheus_external_labels:
|
||||
environment: "alternative"
|
||||
prometheus_targets:
|
||||
node:
|
||||
- targets:
|
||||
- node.demo.do.prometheus.io
|
||||
- influx.example.org:9100
|
||||
labels:
|
||||
env: demo
|
||||
docker:
|
||||
- targets:
|
||||
- demo.do.prometheus.io:8080
|
||||
- influx.example.org:8080
|
||||
labels:
|
||||
env: demo
|
||||
prometheus_scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
metrics_path: "{{ prometheus_metrics_path }}"
|
||||
static_configs:
|
||||
- targets:
|
||||
- "{{ ansible_fqdn | default(ansible_host) | default('localhost')\
|
||||
\ }}:9090"
|
||||
- job_name: "node"
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/node.yml"
|
||||
- job_name: "docker"
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/docker.yml"
|
||||
- job_name: 'blackbox'
|
||||
metrics_path: /probe
|
||||
params:
|
||||
module: [http_2xx]
|
||||
static_configs:
|
||||
- targets:
|
||||
- http://node.demo.do.prometheus.io
|
||||
- http://influx.example.org:9100
|
||||
relabel_configs:
|
||||
- source_labels: [__address__]
|
||||
target_label: __param_target
|
||||
- source_labels: [__param_target]
|
||||
target_label: instance
|
||||
- target_label: __address__
|
||||
replacement: 127.0.0.1:9115 # Blackbox exporter.
|
||||
version: 2.25.2
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
# This is meant to test a local prepared binary. It needs to be updated to support the minium
|
||||
# flag features in the systemd service file.
|
||||
version: 2.25.2
|
||||
tasks:
|
||||
- name: Download prometheus binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz"
|
||||
url: "https://github.com/prometheus/prometheus/releases/download/v{{ version\
|
||||
\ }}/prometheus-{{ version }}.linux-amd64.tar.gz"
|
||||
dest: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_archive
|
||||
|
|
|
@ -52,8 +52,15 @@ def test_file_contents(host, file, content):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("prometheus")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u prometheus --since "1 hour ago"')
|
||||
print("\n==== journalctl -u prometheus Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.prometheus
|
|
@ -1 +1,5 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all: {}
|
||||
|
|
|
@ -60,8 +60,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("prometheus")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u prometheus --since "1 hour ago"')
|
||||
print("\n==== journalctl -u prometheus Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.prometheus
|
||||
vars:
|
||||
prometheus_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
prometheus_version: latest
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("prometheus")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u prometheus --since "1 hour ago"')
|
||||
print("\n==== journalctl -u prometheus Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
group: prometheus
|
||||
mode: 0640
|
||||
validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s"
|
||||
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
||||
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
|
||||
notify:
|
||||
- reload prometheus
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.pushgateway
|
||||
pre_tasks:
|
||||
- name: Create pushgateway cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ pushgateway_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ pushgateway_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ pushgateway_tls_server_config.key_file }}"
|
||||
vars:
|
||||
pushgateway_binary_local_dir: "/tmp/pushgateway-linux-amd64"
|
||||
pushgateway_web_listen_address: "127.0.0.1:8080"
|
||||
|
||||
pushgateway_tls_server_config:
|
||||
cert_file: /etc/pushgateway/tls.cert
|
||||
key_file: /etc/pushgateway/tls.key
|
||||
pushgateway_http_server_config:
|
||||
http2: true
|
||||
pushgateway_basic_auth_users:
|
||||
randomuser: examplepassword
|
|
@ -1 +1,16 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
pushgateway_binary_local_dir: "/tmp/pushgateway-linux-amd64"
|
||||
pushgateway_web_listen_address: "127.0.0.1:8080"
|
||||
pushgateway_tls_server_config:
|
||||
cert_file: /etc/pushgateway/tls.cert
|
||||
key_file: /etc/pushgateway/tls.key
|
||||
pushgateway_http_server_config:
|
||||
http2: true
|
||||
pushgateway_basic_auth_users:
|
||||
randomuser: examplepassword
|
||||
go_arch: amd64
|
||||
pushgateway_version: 1.5.1
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run localhost preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
pushgateway_version: 1.5.1
|
||||
tasks:
|
||||
- name: Download pushgateway binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/pushgateway/releases/download/v{{ pushgateway_version }}/\
|
||||
pushgateway-{{ pushgateway_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/prometheus/pushgateway/releases/download/v{{ pushgateway_version\
|
||||
\ }}/pushgateway-{{ pushgateway_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/pushgateway-{{ pushgateway_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
|
@ -54,3 +51,26 @@
|
|||
csr_path: "/tmp/tls.csr"
|
||||
privatekey_path: "/tmp/tls.key"
|
||||
provider: selfsigned
|
||||
|
||||
- name: Run target preparation
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: Create pushgateway cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ pushgateway_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ pushgateway_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ pushgateway_tls_server_config.key_file }}"
|
||||
|
|
|
@ -20,8 +20,15 @@ def test_directories(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("pushgateway")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u pushgateway --since "1 hour ago"')
|
||||
print("\n==== journalctl -u pushgateway Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.pushgateway
|
||||
vars:
|
||||
pushgateway_web_listen_address: "127.0.0.1:9091"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
pushgateway_web_listen_address: "127.0.0.1:9091"
|
||||
|
|
|
@ -53,8 +53,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("pushgateway")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u pushgateway --since "1 hour ago"')
|
||||
print("\n==== journalctl -u pushgateway Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.pushgateway
|
||||
vars:
|
||||
pushgateway_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
pushgateway_version: latest
|
||||
|
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("pushgateway")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u pushgateway --since "1 hour ago"')
|
||||
print("\n==== journalctl -u pushgateway Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.smokeping_prober
|
||||
pre_tasks:
|
||||
- name: Create smokeping_prober cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ smokeping_prober_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ smokeping_prober_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ smokeping_prober_tls_server_config.key_file }}"
|
||||
vars:
|
||||
smokeping_prober_binary_local_dir: "/tmp/smokeping_prober-linux-amd64"
|
||||
smokeping_prober_web_listen_address: "127.0.0.1:8080"
|
||||
|
||||
smokeping_prober_tls_server_config:
|
||||
cert_file: /etc/smokeping_prober/tls.cert
|
||||
key_file: /etc/smokeping_prober/tls.key
|
||||
smokeping_prober_http_server_config:
|
||||
http2: true
|
||||
smokeping_prober_basic_auth_users:
|
||||
randomuser: examplepassword
|
|
@ -1 +1,16 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
smokeping_prober_binary_local_dir: "/tmp/smokeping_prober-linux-amd64"
|
||||
smokeping_prober_web_listen_address: "127.0.0.1:8080"
|
||||
smokeping_prober_tls_server_config:
|
||||
cert_file: /etc/smokeping_prober/tls.cert
|
||||
key_file: /etc/smokeping_prober/tls.key
|
||||
smokeping_prober_http_server_config:
|
||||
http2: true
|
||||
smokeping_prober_basic_auth_users:
|
||||
randomuser: examplepassword
|
||||
go_arch: amd64
|
||||
smokeping_prober_version: 0.6.1
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
smokeping_prober_version: 0.6.1
|
||||
tasks:
|
||||
- name: Download smokeping_prober binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/superq/smokeping_prober/releases/download/v{{ smokeping_prober_version }}/\
|
||||
smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/superq/smokeping_prober/releases/download/v{{ smokeping_prober_version\
|
||||
\ }}/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
dest: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
@ -22,9 +21,11 @@
|
|||
- name: Unpack smokeping_prober binary
|
||||
become: false
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
src: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
creates: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{ go_arch }}/smokeping_prober"
|
||||
creates: "/tmp/smokeping_prober-{{ smokeping_prober_version }}.linux-{{\
|
||||
\ go_arch }}/smokeping_prober"
|
||||
check_mode: false
|
||||
|
||||
- name: Link to smokeping_prober binaries directory
|
||||
|
@ -54,3 +55,26 @@
|
|||
csr_path: "/tmp/tls.csr"
|
||||
privatekey_path: "/tmp/tls.key"
|
||||
provider: selfsigned
|
||||
|
||||
- name: Run target preparation
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: Create smokeping_prober cert dir
|
||||
ansible.builtin.file:
|
||||
path: "{{ smokeping_prober_tls_server_config.cert_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ smokeping_prober_tls_server_config.cert_file }}"
|
||||
- src: "/tmp/tls.key"
|
||||
dest: "{{ smokeping_prober_tls_server_config.key_file }}"
|
||||
|
|
|
@ -20,8 +20,15 @@ def test_directories(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("smokeping_prober")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u smokeping_prober --since "1 hour ago"')
|
||||
print("\n==== journalctl -u smokeping_prober Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.smokeping_prober
|
||||
vars:
|
||||
smokeping_prober_web_listen_address: "127.0.0.1:9374"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
smokeping_prober_web_listen_address: "127.0.0.1:9374"
|
||||
|
|
|
@ -53,8 +53,15 @@ def test_user(host):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("smokeping_prober")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u smokeping_prober --since "1 hour ago"')
|
||||
print("\n==== journalctl -u smokeping_prober Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.smokeping_prober
|
||||
vars:
|
||||
smokeping_prober_version: latest
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
smokeping_prober_version: latest
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
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/smokeping_prober.service",
|
||||
"/usr/local/bin/smokeping_prober"
|
||||
])
|
||||
def test_files(host, files):
|
||||
f = host.file(files)
|
||||
assert f.exists
|
||||
assert f.is_file
|
||||
|
||||
|
||||
def test_service(host):
|
||||
s = host.service("smokeping_prober")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
|
||||
|
||||
def test_protecthome_property(host):
|
||||
s = host.service("smokeping_prober")
|
||||
p = s.systemd_properties
|
||||
assert p.get("ProtectHome") == "yes"
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
s = host.socket("tcp://0.0.0.0:9374")
|
||||
assert s.is_listening
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("smokeping_prober")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u smokeping_prober --since "1 hour ago"')
|
||||
print("\n==== journalctl -u smokeping_prober Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
||||
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
|
||||
notify: restart smokeping_prober
|
||||
|
||||
- name: Configure smokeping_prober web config
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- prometheus.prometheus.snmp_exporter
|
||||
vars:
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
||||
snmp_exporter_config_file: snmp.yml
|
|
@ -1 +1,7 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
||||
snmp_exporter_config_file: ${MOLECULE_SCENARIO_DIRECTORY}/templates/snmp.yml
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
---
|
||||
if_mib:
|
||||
modules:
|
||||
if_mib:
|
||||
get:
|
||||
- 1.3.6.1.2.1.1.3.0
|
||||
- 1.3.6.1.2.1.1.3.0
|
||||
metrics:
|
||||
- name: sysUpTime
|
||||
oid: 1.3.6.1.2.1.1.3
|
||||
type: gauge
|
||||
help: The time (in hundredths of a second) since the network management portion
|
||||
of the system was last re-initialized. - 1.3.6.1.2.1.1.3
|
||||
- name: sysUpTime
|
||||
oid: 1.3.6.1.2.1.1.3
|
||||
type: gauge
|
||||
help: The time (in hundredths of a second) since the network management portion
|
||||
of the system was last re-initialized. - 1.3.6.1.2.1.1.3
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("snmp_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u snmp_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u snmp_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- prometheus.prometheus.snmp_exporter
|
||||
vars:
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
|
@ -1 +1,6 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
||||
|
|
|
@ -22,8 +22,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("snmp_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u snmp_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u snmp_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
||||
no_log: "{{ false if (lookup('env', 'CI')) or (lookup('env', 'MOLECULE_PROVISIONER_NAME')) else true }}"
|
||||
notify:
|
||||
- reload snmp exporter
|
||||
when: (snmp_exporter_config_file)
|
||||
|
|
|
@ -1 +1,9 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
systemd_exporter_binary_local_dir: "/tmp/systemd_exporter-linux-amd64"
|
||||
systemd_exporter_web_listen_address: "127.0.0.1:9000"
|
||||
go_arch: amd64
|
||||
systemd_exporter_version: 0.4.0
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
- name: Run role
|
||||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus.prometheus.systemd_exporter
|
||||
vars:
|
||||
systemd_exporter_binary_local_dir: "/tmp/systemd_exporter-linux-amd64"
|
||||
systemd_exporter_web_listen_address: "127.0.0.1:9000"
|
|
@ -1,17 +1,16 @@
|
|||
---
|
||||
- name: Prepare
|
||||
- name: Run local preparation
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
go_arch: amd64
|
||||
systemd_exporter_version: 0.4.0
|
||||
tasks:
|
||||
- name: Download systemd_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus-community/systemd_exporter/releases/download/v{{ systemd_exporter_version }}/\
|
||||
systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
url: "https://github.com/prometheus-community/systemd_exporter/releases/download/v{{\
|
||||
\ systemd_exporter_version }}/systemd_exporter-{{ systemd_exporter_version\
|
||||
\ }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
mode: 0644
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
@ -22,9 +21,11 @@
|
|||
- name: Unpack systemd_exporter binary
|
||||
become: false
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
src: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch\
|
||||
\ }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
creates: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}/systemd_exporter"
|
||||
creates: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-{{\
|
||||
\ go_arch }}/systemd_exporter"
|
||||
check_mode: false
|
||||
|
||||
- name: Link to systemd_exporter binaries directory
|
||||
|
|
|
@ -10,8 +10,15 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("systemd_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u systemd_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u systemd_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all: {}
|
||||
|
|
|
@ -41,10 +41,17 @@ def test_user(host):
|
|||
assert host.user("systemd-exporter").home == "/"
|
||||
|
||||
|
||||
# def test_service(host):
|
||||
# s = host.service("systemd_exporter")
|
||||
# # assert s.is_enabled
|
||||
# assert s.is_running
|
||||
def test_service(host):
|
||||
s = host.service("systemd_exporter")
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u systemd_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u systemd_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
---
|
||||
provisioner:
|
||||
inventory:
|
||||
group_vars:
|
||||
all: {}
|
||||
|
|
|
@ -21,8 +21,15 @@ def test_files(host, files):
|
|||
|
||||
def test_service(host):
|
||||
s = host.service("systemd_exporter")
|
||||
# assert s.is_enabled
|
||||
assert s.is_running
|
||||
try:
|
||||
assert s.is_running
|
||||
except AssertionError:
|
||||
# Capture service logs
|
||||
journal_output = host.run('journalctl -u systemd_exporter --since "1 hour ago"')
|
||||
print("\n==== journalctl -u systemd_exporter Output ====\n")
|
||||
print(journal_output)
|
||||
print("\n============================================\n")
|
||||
raise # Re-raise the original assertion error
|
||||
|
||||
|
||||
def test_socket(host):
|
Loading…
Reference in a new issue