mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 11:53:12 +00:00
enhancement(mysqld_exporter): allows using multiple web listen addresses
Signed-off-by: Christian Krause <christian.krause@idiv.de>
This commit is contained in:
parent
9e84276add
commit
dce2e959d9
4 changed files with 37 additions and 10 deletions
|
@ -4,7 +4,9 @@ provisioner:
|
||||||
group_vars:
|
group_vars:
|
||||||
all:
|
all:
|
||||||
mysqld_exporter_binary_local_dir: "/tmp/mysqld_exporter-linux-amd64"
|
mysqld_exporter_binary_local_dir: "/tmp/mysqld_exporter-linux-amd64"
|
||||||
mysqld_exporter_web_listen_address: "127.0.0.1:8080"
|
mysqld_exporter_web_listen_address:
|
||||||
|
- '127.0.0.1:8080'
|
||||||
|
- '127.0.1.1:8080'
|
||||||
mysqld_exporter_enabled_collectors:
|
mysqld_exporter_enabled_collectors:
|
||||||
- slave_hosts
|
- slave_hosts
|
||||||
mysqld_exporter_disabled_collectors:
|
mysqld_exporter_disabled_collectors:
|
||||||
|
@ -18,4 +20,4 @@ provisioner:
|
||||||
mysqld_exporter_basic_auth_users:
|
mysqld_exporter_basic_auth_users:
|
||||||
randomuser: examplepassword
|
randomuser: examplepassword
|
||||||
go_arch: amd64
|
go_arch: amd64
|
||||||
mysqld_exporter_version: 0.13.0
|
mysqld_exporter_version: 0.15.0
|
||||||
|
|
|
@ -3,6 +3,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import testinfra.utils.ansible_runner
|
import testinfra.utils.ansible_runner
|
||||||
|
import pytest
|
||||||
|
|
||||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
@ -21,10 +22,9 @@ def test_service(host):
|
||||||
raise # Re-raise the original assertion error
|
raise # Re-raise the original assertion error
|
||||||
|
|
||||||
|
|
||||||
def test_socket(host):
|
@pytest.mark.parametrize("sockets", [
|
||||||
sockets = [
|
"tcp://127.0.0.1:8080",
|
||||||
"tcp://127.0.0.1:8080"
|
"tcp://127.0.1.1:8080",
|
||||||
]
|
])
|
||||||
for socket in sockets:
|
def test_socket(host, sockets):
|
||||||
s = host.socket(socket)
|
assert host.socket(sockets).is_listening
|
||||||
assert s.is_listening
|
|
||||||
|
|
|
@ -20,10 +20,26 @@
|
||||||
ansible.builtin.package_facts:
|
ansible.builtin.package_facts:
|
||||||
when: "not 'packages' in ansible_facts"
|
when: "not 'packages' in ansible_facts"
|
||||||
|
|
||||||
|
- name: Assert that used version supports listen address type
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- >-
|
||||||
|
mysqld_exporter_web_listen_address is string
|
||||||
|
or
|
||||||
|
(
|
||||||
|
mysqld_exporter_version is version('0.15.0', '>=') and
|
||||||
|
mysqld_exporter_web_listen_address | type_debug == "list"
|
||||||
|
)
|
||||||
|
|
||||||
- name: Naive assertion of proper listen address
|
- name: Naive assertion of proper listen address
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "':' in mysqld_exporter_web_listen_address"
|
- >-
|
||||||
|
[mysqld_exporter_web_listen_address] |
|
||||||
|
flatten |
|
||||||
|
reject('match', '.+:\\d+$') |
|
||||||
|
list |
|
||||||
|
length == 0
|
||||||
|
|
||||||
- name: Assert collectors are not both disabled and enabled at the same time
|
- name: Assert collectors are not both disabled and enabled at the same time
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
|
|
|
@ -26,7 +26,16 @@ ExecStart={{ mysqld_exporter_binary_install_dir }}/mysqld_exporter \
|
||||||
{% if mysqld_exporter_tls_server_config | length > 0 or mysqld_exporter_http_server_config | length > 0 or mysqld_exporter_basic_auth_users | length > 0 %}
|
{% if mysqld_exporter_tls_server_config | length > 0 or mysqld_exporter_http_server_config | length > 0 or mysqld_exporter_basic_auth_users | length > 0 %}
|
||||||
--web.config.file={{ mysqld_exporter_config_dir }}/web_config.yaml \
|
--web.config.file={{ mysqld_exporter_config_dir }}/web_config.yaml \
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if mysqld_exporter_version is version('0.15.0', '>=') and
|
||||||
|
mysqld_exporter_web_listen_address is iterable and
|
||||||
|
mysqld_exporter_web_listen_address is not mapping and
|
||||||
|
mysqld_exporter_web_listen_address is not string %}
|
||||||
|
{% for address in mysqld_exporter_web_listen_address %}
|
||||||
|
--web.listen-address={{ address }} \
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
--web.listen-address={{ mysqld_exporter_web_listen_address }} \
|
--web.listen-address={{ mysqld_exporter_web_listen_address }} \
|
||||||
|
{% endif %}
|
||||||
--web.telemetry-path={{ mysqld_exporter_web_telemetry_path }} \
|
--web.telemetry-path={{ mysqld_exporter_web_telemetry_path }} \
|
||||||
--config.my-cnf={{ mysqld_exporter_config_dir }}/{{ mysqld_exporter_config_file }}
|
--config.my-cnf={{ mysqld_exporter_config_dir }}/{{ mysqld_exporter_config_file }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue