Merge pull request #197 from gardar/molecule-testinfra

skip_changelog: molecule and testinfra cleanup
This commit is contained in:
gardar 2023-08-21 18:22:30 +00:00 committed by GitHub
commit 255dabc9aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 793 additions and 659 deletions

View file

@ -78,3 +78,6 @@ platforms:
command: /lib/systemd/systemd
verifier:
name: testinfra
provisioner:
playbooks:
converge: "${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/converge.yml"

View 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 }}"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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", [

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -1,6 +0,0 @@
---
- name: Converge
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.blackbox_exporter

View file

@ -1 +1,5 @@
---
provisioner:
inventory:
group_vars:
all: {}

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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 }}"

View 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):

View file

@ -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"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
chrony_exporter_web_listen_address: "127.0.0.1:9123"

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.chrony_exporter
vars:
chrony_exporter_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
chrony_exporter_version: latest

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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 }}"

View 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):

View file

@ -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"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
mysqld_exporter_web_listen_address: "127.0.0.1:9104"

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.mysqld_exporter
vars:
mysqld_exporter_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
mysqld_exporter_version: latest

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 }}"

View 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):

View file

@ -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"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
node_exporter_web_listen_address: "127.0.0.1:9100"

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.node_exporter
vars:
node_exporter_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
node_exporter_version: latest

View file

@ -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):

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -1,6 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.prometheus

View file

@ -1 +1,5 @@
---
provisioner:
inventory:
group_vars:
all: {}

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.prometheus
vars:
prometheus_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
prometheus_version: latest

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 }}"

View 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):

View file

@ -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"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
pushgateway_web_listen_address: "127.0.0.1:9091"

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.pushgateway
vars:
pushgateway_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
pushgateway_version: latest

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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 }}"

View 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):

View file

@ -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"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
smokeping_prober_web_listen_address: "127.0.0.1:9374"

View file

@ -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):

View file

@ -1,8 +0,0 @@
---
- name: Run role
hosts: all
any_errors_fatal: true
roles:
- prometheus.prometheus.smokeping_prober
vars:
smokeping_prober_version: latest

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
smokeping_prober_version: latest

View file

@ -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

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -1,7 +0,0 @@
---
- name: Converge
hosts: all
roles:
- prometheus.prometheus.snmp_exporter
vars:
snmp_exporter_web_listen_address: "127.0.0.1:9116"

View file

@ -1 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
snmp_exporter_web_listen_address: "127.0.0.1:9116"

View file

@ -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):

View file

@ -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)

View 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

View file

@ -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"

View file

@ -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

View file

@ -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):

View file

@ -1 +1,5 @@
---
provisioner:
inventory:
group_vars:
all: {}

View file

@ -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):

View file

@ -1 +1,5 @@
---
provisioner:
inventory:
group_vars:
all: {}

View file

@ -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):