enhancement(node_exporter): add skip_install variable

This is similar to prometheus_skip_install variable and does what the
name says: when set, it won't try to re-download the node exporter
binary

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt 2023-03-20 15:54:10 +01:00
parent ba3be35fe7
commit c1a80960f6
No known key found for this signature in database
GPG key ID: F3F92DA383FDDE09
5 changed files with 16 additions and 3 deletions

View file

@ -19,6 +19,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `node_exporter_version` | 1.1.2 | Node exporter package version. Also accepts `latest` as parameter. |
| `node_exporter_skip_install` | false | Node exporter installation tasks gets skipped when set to true. |
| `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 |

View file

@ -4,6 +4,7 @@ node_exporter_binary_local_dir: ""
node_exporter_binary_url: "https://github.com/{{ _node_exporter_repo }}/releases/download/v{{ node_exporter_version }}/\
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
node_exporter_checksums_url: "https://github.com/{{ _node_exporter_repo }}/releases/download/v{{ node_exporter_version }}/sha256sums.txt"
node_exporter_skip_install: false
node_exporter_web_listen_address: "0.0.0.0:9100"
node_exporter_web_telemetry_path: "/metrics"

View file

@ -11,6 +11,10 @@ argument_specs:
node_exporter_version:
description: "Node exporter package version. Also accepts latest as parameter."
default: "1.1.2"
node_exporter_skip_install:
description: "Node exporter installation tasks gets skipped when set to true."
type: bool
default: false
node_exporter_binary_local_dir:
description:
- "Enables the use of local packages instead of those distributed on github."

View file

@ -18,7 +18,9 @@
when: node_exporter_system_user != "root"
- name: Discover latest version
when: node_exporter_binary_local_dir | length == 0
when:
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install
block:
- name: Download node_exporter binary to local folder
@ -61,5 +63,7 @@
mode: 0755
owner: root
group: root
when: node_exporter_binary_local_dir | length > 0
when:
- node_exporter_binary_local_dir | length > 0
- not node_exporter_skip_install
notify: restart node_exporter

View file

@ -82,9 +82,12 @@
when:
- node_exporter_version == "latest"
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install
- name: Get node_exporter binary checksum
when: node_exporter_binary_local_dir | length == 0
when:
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install
block:
- name: Get checksum list from github
ansible.builtin.set_fact: