From 9f4c0243e5dfbbc889307129984167fdc176de64 Mon Sep 17 00:00:00 2001 From: gardar Date: Wed, 22 Feb 2023 16:41:16 +0000 Subject: [PATCH 1/5] refactor: support customizing alertmanager url/mirror Signed-off-by: gardar --- roles/alertmanager/README.md | 2 ++ roles/alertmanager/defaults/main.yml | 3 +++ roles/alertmanager/tasks/install.yml | 3 +-- roles/alertmanager/tasks/preflight.yml | 3 +-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/roles/alertmanager/README.md b/roles/alertmanager/README.md index e32979f9..3b088887 100644 --- a/roles/alertmanager/README.md +++ b/roles/alertmanager/README.md @@ -20,6 +20,8 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | -------------- | ------------- | -----------------------------------| | `alertmanager_version` | 0.21.0 | Alertmanager package version. Also accepts `latest` as parameter. | | `alertmanager_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `alertmanager` AND `amtool` binaries are stored on host on which ansible is ran. This overrides `alertmanager_version` parameter | +| `alertmanager_binary_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz` | URL of the alertmanager binaries .tar.gz file | +| `alertmanager_checksums_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt` | URL of the alertmanager checksums file | | `alertmanager_web_listen_address` | 0.0.0.0:9093 | Address on which alertmanager will be listening | | `alertmanager_web_external_url` | http://localhost:9093/ | External address on which alertmanager is available. Useful when behind reverse proxy. Ex. example.org/alertmanager | | `alertmanager_config_dir` | /etc/alertmanager | Path to directory with alertmanager configuration | diff --git a/roles/alertmanager/defaults/main.yml b/roles/alertmanager/defaults/main.yml index 83a12e8d..5f06730c 100644 --- a/roles/alertmanager/defaults/main.yml +++ b/roles/alertmanager/defaults/main.yml @@ -1,6 +1,9 @@ --- alertmanager_version: 0.21.0 alertmanager_binary_local_dir: '' +alertmanager_binary_url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/\ + alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz" +alertmanager_checksums_url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt" alertmanager_config_dir: /etc/alertmanager alertmanager_db_dir: /var/lib/alertmanager diff --git a/roles/alertmanager/tasks/install.yml b/roles/alertmanager/tasks/install.yml index 66002c46..e1a39155 100644 --- a/roles/alertmanager/tasks/install.yml +++ b/roles/alertmanager/tasks/install.yml @@ -33,8 +33,7 @@ - name: Download alertmanager binary to local folder become: false ansible.builtin.get_url: - url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/\ - alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz" + url: "{{ alertmanager_binary_url }}" dest: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz" checksum: "sha256:{{ __alertmanager_checksum }}" mode: 0644 diff --git a/roles/alertmanager/tasks/preflight.yml b/roles/alertmanager/tasks/preflight.yml index f4296f49..c6b54104 100644 --- a/roles/alertmanager/tasks/preflight.yml +++ b/roles/alertmanager/tasks/preflight.yml @@ -33,8 +33,7 @@ block: - name: "Get checksum list" ansible.builtin.set_fact: - __alertmanager_checksums: "{{ lookup('url', 'https://github.com/prometheus/alertmanager/releases/download/v' + alertmanager_version + - '/sha256sums.txt', wantlist=True) | list }}" + __alertmanager_checksums: "{{ lookup('url', alertmanager_checksums_url, wantlist=True) | list }}" run_once: true until: __alertmanager_checksums is search('linux-' + go_arch + '.tar.gz') retries: 10 From e57ae9b9d70229e740b6875b51b6deeb1f09071a Mon Sep 17 00:00:00 2001 From: gardar Date: Wed, 22 Feb 2023 17:20:00 +0000 Subject: [PATCH 2/5] refactor: support customizing prometheus url/mirror Signed-off-by: gardar --- roles/prometheus/README.md | 2 ++ roles/prometheus/defaults/main.yml | 3 +++ roles/prometheus/tasks/install.yml | 3 +-- roles/prometheus/tasks/preflight.yml | 3 +-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/roles/prometheus/README.md b/roles/prometheus/README.md index 07bb1f3e..e63d8c40 100644 --- a/roles/prometheus/README.md +++ b/roles/prometheus/README.md @@ -26,6 +26,8 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | `prometheus_skip_install` | false | Prometheus installation tasks gets skipped when set to true. | | `prometheus_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `prometheus` AND `promtool` binaries are stored on host on which ansible is ran. This overrides `prometheus_version` parameter | | `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration | +| `prometheus_binary_url` | `https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz` | URL of the prometheus binaries .tar.gz file | +| `prometheus_checksums_url` | `https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/sha256sums.txt` | URL of the prometheus checksums file | | `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database | | `prometheus_read_only_dirs`| [] | Additional paths that Prometheus is allowed to read (useful for SSL certs outside of the config directory) | | `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening | diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml index d9677196..9aa701ba 100644 --- a/roles/prometheus/defaults/main.yml +++ b/roles/prometheus/defaults/main.yml @@ -1,6 +1,9 @@ --- prometheus_version: 2.27.0 prometheus_binary_local_dir: '' +prometheus_binary_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/\ + prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" +prometheus_checksums_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/sha256sums.txt" prometheus_skip_install: false prometheus_config_dir: /etc/prometheus diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml index 0055cfcb..47a87404 100644 --- a/roles/prometheus/tasks/install.yml +++ b/roles/prometheus/tasks/install.yml @@ -43,8 +43,7 @@ - name: Download prometheus binary to local folder become: false ansible.builtin.get_url: - url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/\ - prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + url: "{{ prometheus_binary_url }}" dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" checksum: "sha256:{{ __prometheus_checksum }}" mode: 0644 diff --git a/roles/prometheus/tasks/preflight.yml b/roles/prometheus/tasks/preflight.yml index 7db7b1a3..3eaa0f06 100644 --- a/roles/prometheus/tasks/preflight.yml +++ b/roles/prometheus/tasks/preflight.yml @@ -91,8 +91,7 @@ block: - name: "Get checksum list" ansible.builtin.set_fact: - __prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', - wantlist=True) | list }}" + __prometheus_checksums: "{{ lookup('url', prometheus_checksums_url, wantlist=True) | list }}" run_once: true until: __prometheus_checksums is search('linux-' + go_arch + '.tar.gz') retries: 10 From 12a8260b2bd836db40070b9b9ab1c88b9109a92a Mon Sep 17 00:00:00 2001 From: gardar Date: Wed, 22 Feb 2023 17:29:16 +0000 Subject: [PATCH 3/5] refactor: support customizing node_exporter url/mirror Signed-off-by: gardar --- roles/node_exporter/README.md | 2 ++ roles/node_exporter/defaults/main.yml | 4 ++++ roles/node_exporter/tasks/install.yml | 3 +-- roles/node_exporter/tasks/preflight.yml | 3 +-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/node_exporter/README.md b/roles/node_exporter/README.md index 90fa5a50..1c9852f6 100644 --- a/roles/node_exporter/README.md +++ b/roles/node_exporter/README.md @@ -24,6 +24,8 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | -------------- | ------------- | -----------------------------------| | `node_exporter_version` | 1.1.2 | Node exporter package version. Also accepts latest as parameter. | | `node_exporter_binary_local_dir` | "" | Enables the use of local packages instead of those distributed on github. The parameter may be set to a directory where the `node_exporter` binary is stored on the host where ansible is run. This overrides the `node_exporter_version` parameter | +| `node_exporter_binary_url` | `https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz` | URL of the node exporter binaries .tar.gz file | +| `node_exporter_checksums_url` | `https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/sha256sums.txt` | URL of the node exporter checksums file | | `node_exporter_web_listen_address` | "0.0.0.0:9100" | Address on which node exporter will listen | | `node_exporter_web_telemetry_path` | "/metrics" | Path under which to expose metrics | | `node_exporter_enabled_collectors` | ```["systemd",{textfile: {directory: "{{node_exporter_textfile_dir}}"}}]``` | List of dicts defining additionally enabled collectors and their configuration. It adds collectors to [those enabled by default](https://github.com/prometheus/node_exporter#enabled-by-default). | diff --git a/roles/node_exporter/defaults/main.yml b/roles/node_exporter/defaults/main.yml index 0f8e6d9a..938bd803 100644 --- a/roles/node_exporter/defaults/main.yml +++ b/roles/node_exporter/defaults/main.yml @@ -1,6 +1,10 @@ --- node_exporter_version: 1.1.2 node_exporter_binary_local_dir: "" +node_exporter_binary_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/\ + node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz" +node_exporter_checksums_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/sha256sums.txt" + node_exporter_web_listen_address: "0.0.0.0:9100" node_exporter_web_telemetry_path: "/metrics" diff --git a/roles/node_exporter/tasks/install.yml b/roles/node_exporter/tasks/install.yml index 3e345527..f011ecd1 100644 --- a/roles/node_exporter/tasks/install.yml +++ b/roles/node_exporter/tasks/install.yml @@ -24,8 +24,7 @@ - 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: "{{ node_exporter_binary_url }}" dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz" checksum: "sha256:{{ __node_exporter_checksum }}" mode: '0644' diff --git a/roles/node_exporter/tasks/preflight.yml b/roles/node_exporter/tasks/preflight.yml index 34ef6296..5a2993ea 100644 --- a/roles/node_exporter/tasks/preflight.yml +++ b/roles/node_exporter/tasks/preflight.yml @@ -86,8 +86,7 @@ block: - name: Get checksum list from github ansible.builtin.set_fact: - __node_exporter_checksums: "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + - '/sha256sums.txt', wantlist=True) | list }}" + __node_exporter_checksums: "{{ lookup('url', node_exporter_checksums_url, wantlist=True) | list }}" run_once: true until: __node_exporter_checksums is search('linux-' + go_arch + '.tar.gz') retries: 10 From 7f81fc02168fabb41126f948a9d97c76666ae463 Mon Sep 17 00:00:00 2001 From: gardar Date: Wed, 22 Feb 2023 17:37:31 +0000 Subject: [PATCH 4/5] refactor: support customizing snmp_exporter url/mirror Signed-off-by: gardar --- roles/snmp_exporter/README.md | 2 ++ roles/snmp_exporter/defaults/main.yml | 3 +++ roles/snmp_exporter/tasks/install.yml | 3 +-- roles/snmp_exporter/tasks/preflight.yml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/snmp_exporter/README.md b/roles/snmp_exporter/README.md index 9b8b6230..fccca238 100644 --- a/roles/snmp_exporter/README.md +++ b/roles/snmp_exporter/README.md @@ -17,6 +17,8 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | Name | Default Value | Description | | -------------- | ------------- | -----------------------------------| | `snmp_exporter_version` | 0.19.0 | SNMP exporter package version | +| `snmp_exporter_binary_url` | `https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz` | URL of the snmp exporter binaries .tar.gz file | +| `snmp_exporter_checksums_url` | `https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/sha256sums.txt` | URL of the snmp exporter checksums file | | `snmp_exporter_web_listen_address` | "0.0.0.0:9116" | Address on which SNMP exporter will be listening | | `snmp_exporter_config_file` | "" | If this is empty, role will download snmp.yml file from https://github.com/prometheus/snmp_exporter. Otherwise this should contain path to file with custom snmp exporter configuration | diff --git a/roles/snmp_exporter/defaults/main.yml b/roles/snmp_exporter/defaults/main.yml index 441042ac..7498ec0d 100644 --- a/roles/snmp_exporter/defaults/main.yml +++ b/roles/snmp_exporter/defaults/main.yml @@ -1,5 +1,8 @@ --- snmp_exporter_version: 0.19.0 +snmp_exporter_binary_url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/\ + snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz" +snmp_exporter_checksums_url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/sha256sums.txt" snmp_exporter_web_listen_address: "0.0.0.0:9116" snmp_exporter_log_level: info diff --git a/roles/snmp_exporter/tasks/install.yml b/roles/snmp_exporter/tasks/install.yml index b2a16fb6..4e4a39aa 100644 --- a/roles/snmp_exporter/tasks/install.yml +++ b/roles/snmp_exporter/tasks/install.yml @@ -2,8 +2,7 @@ - name: Download snmp_exporter binary to local folder become: false ansible.builtin.get_url: - url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/\ - snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz" + url: "{{ snmp_exporter_binary_url }}" dest: "/tmp" checksum: "sha256:{{ snmp_exporter_checksum }}" mode: 0644 diff --git a/roles/snmp_exporter/tasks/preflight.yml b/roles/snmp_exporter/tasks/preflight.yml index 48639a24..a5000ad5 100644 --- a/roles/snmp_exporter/tasks/preflight.yml +++ b/roles/snmp_exporter/tasks/preflight.yml @@ -3,5 +3,5 @@ ansible.builtin.set_fact: snmp_exporter_checksum: "{{ item.split(' ')[0] }}" with_items: - - "{{ lookup('url', 'https://github.com/prometheus/snmp_exporter/releases/download/v' + snmp_exporter_version + '/sha256sums.txt', wantlist=True) | list }}" + - "{{ lookup('url', snmp_exporter_checksums_url, wantlist=True) | list }}" when: "('linux-' + (go_arch_map[ansible_architecture] | default(ansible_architecture)) + '.tar.gz') in item" From 9de5b0518dbef9093b595339761da50a95231f3c Mon Sep 17 00:00:00 2001 From: gardar Date: Wed, 22 Feb 2023 17:37:49 +0000 Subject: [PATCH 5/5] refactor: support customizing blackbox_exporter url/mirror Signed-off-by: gardar --- roles/blackbox_exporter/README.md | 1 + roles/blackbox_exporter/defaults/main.yml | 3 +++ roles/blackbox_exporter/tasks/install.yml | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/roles/blackbox_exporter/README.md b/roles/blackbox_exporter/README.md index 42f181c9..83a8a267 100644 --- a/roles/blackbox_exporter/README.md +++ b/roles/blackbox_exporter/README.md @@ -18,6 +18,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | Name | Default Value | Description | | -------------- | ------------- | -----------------------------------| | `blackbox_exporter_version` | 0.18.0 | Blackbox exporter package version | +| `blackbox_exporter_binary_url` | `"https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"` | URL of the blackbox exporter binaries .tar.gz file | | `blackbox_exporter_web_listen_address` | 0.0.0.0:9115 | Address on which blackbox exporter will be listening | | `blackbox_exporter_cli_flags` | {} | Additional configuration flags passed to blackbox exporter binary at startup | | `blackbox_exporter_configuration_modules` | http_2xx: { prober: http, timeout: 5s, http: '' } | | diff --git a/roles/blackbox_exporter/defaults/main.yml b/roles/blackbox_exporter/defaults/main.yml index 6444d45a..c35805cc 100644 --- a/roles/blackbox_exporter/defaults/main.yml +++ b/roles/blackbox_exporter/defaults/main.yml @@ -1,5 +1,8 @@ --- blackbox_exporter_version: 0.18.0 +blackbox_exporter_binary_url: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/\ + blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | + default(ansible_architecture) }}.tar.gz" blackbox_exporter_web_listen_address: "0.0.0.0:9115" diff --git a/roles/blackbox_exporter/tasks/install.yml b/roles/blackbox_exporter/tasks/install.yml index 0a362b3c..0149fd6f 100644 --- a/roles/blackbox_exporter/tasks/install.yml +++ b/roles/blackbox_exporter/tasks/install.yml @@ -16,8 +16,7 @@ - name: Download blackbox exporter binary to local folder become: false ansible.builtin.unarchive: - src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/\ - blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz" + src: "{{ blackbox_exporter_binary_url }}" dest: "/tmp" remote_src: true creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/\