diff --git a/roles/_common/meta/argument_specs.yml b/roles/_common/meta/argument_specs.yml index 7642a47c6..fd2fa3e80 100644 --- a/roles/_common/meta/argument_specs.yml +++ b/roles/_common/meta/argument_specs.yml @@ -81,6 +81,9 @@ argument_specs: {{ ('python-apt' if ansible_python_version is version('3', '<') else 'python3-apt') }} {% else %}\ {% endif %}" + _common_web_listen_address: + description: "Address on which to listen" + default: "" selinux: short_description: "Internal only - common selinux configuration tasks" description: "Internal only - selinux requirements" diff --git a/roles/_common/tasks/preflight.yml b/roles/_common/tasks/preflight.yml index 4a8006e58..6ea26f62a 100644 --- a/roles/_common/tasks/preflight.yml +++ b/roles/_common/tasks/preflight.yml @@ -74,3 +74,14 @@ - "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_configure" - install - "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_install" + +- name: Naive assertion of proper listen address + ansible.builtin.assert: + that: + - >- + [_common_web_listen_address] | + flatten | + reject('match', '.+:\\d+$') | + list | + length == 0 + when: (_common_web_listen_address) diff --git a/roles/_common/vars/main.yml b/roles/_common/vars/main.yml index dbda12bc2..8d8beb8b8 100644 --- a/roles/_common/vars/main.yml +++ b/roles/_common/vars/main.yml @@ -18,6 +18,7 @@ _common_binary_unarchive_opts: "" _common_tls_server_config: {} _common_http_server_config: {} _common_basic_auth_users: {} +_common_web_listen_address: "" # Variables that should not be overwritten __common_binary_basename: "{{ _common_binary_url | urlsplit('path') | basename }}" __common_github_api_headers: "{{ {'GITHUB_TOKEN': lookup('ansible.builtin.env', 'GITHUB_TOKEN')} if (lookup('ansible.builtin.env', 'GITHUB_TOKEN')) else {} }}" diff --git a/roles/alertmanager/tasks/preflight.yml b/roles/alertmanager/tasks/preflight.yml index ea6f2a33a..f4b88d321 100644 --- a/roles/alertmanager/tasks/preflight.yml +++ b/roles/alertmanager/tasks/preflight.yml @@ -3,6 +3,8 @@ ansible.builtin.include_role: name: prometheus.prometheus._common tasks_from: preflight.yml + vars: + _common_web_listen_address: "{{ alertmanager_web_listen_address }}" - name: Assert that used version supports listen address type ansible.builtin.assert: @@ -15,16 +17,6 @@ alertmanager_web_listen_address | type_debug == "list" ) -- name: Naive assertion of proper listen address - ansible.builtin.assert: - that: - - >- - [alertmanager_web_listen_address] | - flatten | - reject('match', '.+:\\d+$') | - list | - length == 0 - - name: Discover latest version ansible.builtin.set_fact: alertmanager_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _alertmanager_repo }}/releases/latest', headers=_github_api_headers, diff --git a/roles/bind_exporter/tasks/preflight.yml b/roles/bind_exporter/tasks/preflight.yml index 82ff04faf..e777f5db4 100644 --- a/roles/bind_exporter/tasks/preflight.yml +++ b/roles/bind_exporter/tasks/preflight.yml @@ -3,16 +3,8 @@ ansible.builtin.include_role: name: prometheus.prometheus._common tasks_from: preflight.yml - -- name: Naive assertion of proper listen address - ansible.builtin.assert: - that: - - >- - [bind_exporter_web_listen_address] | - flatten | - reject('match', '.+:\\d+$') | - list | - length == 0 + vars: + _common_web_listen_address: "{{ bind_exporter_web_listen_address }}" - name: Assert that TLS config is correct when: bind_exporter_tls_server_config | length > 0 diff --git a/roles/blackbox_exporter/tasks/preflight.yml b/roles/blackbox_exporter/tasks/preflight.yml index 7f8c98e8b..a4816112c 100644 --- a/roles/blackbox_exporter/tasks/preflight.yml +++ b/roles/blackbox_exporter/tasks/preflight.yml @@ -5,6 +5,7 @@ tasks_from: preflight.yml vars: _common_dependencies: "{{ _blackbox_exporter_dependencies }}" + _common_web_listen_address: "{{ blackbox_exporter_web_listen_address }}" - name: Assert that used version supports listen address type ansible.builtin.assert: @@ -17,16 +18,6 @@ blackbox_exporter_web_listen_address | type_debug == "list" ) -- name: Naive assertion of proper listen address - ansible.builtin.assert: - that: - - >- - [blackbox_exporter_web_listen_address] | - flatten | - reject('match', '.+:\\d+$') | - list | - length == 0 - - name: Discover latest version ansible.builtin.set_fact: blackbox_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _blackbox_exporter_repo }}/releases/latest', headers=_github_api_headers,