Skip to content

Commit 5355706

Browse files
authored
Rename nodeexporter role to node_exporter and update documentation, specs, and linting fixes (#209)
* Update (and rename) node exporter role for ansible-lint, argument specs, README, and future redirects * Remove nodeexporter role (was renamed) * Add symlink to renamed node exporter role Signed-off-by: Webster Mudge <[email protected]>
1 parent 8eaef2e commit 5355706

File tree

9 files changed

+176
-40
lines changed

9 files changed

+176
-40
lines changed

meta/runtime.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
3+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -14,12 +14,17 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
requires_ansible: ">=2.10"
17+
requires_ansible: ">=2.15.0"
1818

1919
plugin_routing:
20-
role:
20+
role: # Not yet supported
2121
rdbms.server:
2222
deprecation:
2323
removal_version: 3.0.0
2424
warning_text: Use cloudera.exe.rdbms_server instead of this nested role.
2525
redirect: cloudera.exe.rdbms_server
26+
nodeexporter:
27+
deprecation:
28+
removal_version: 6.0.0
29+
warning_text: Please update references to the renamed role, cloudera.exe.node_exporter
30+
redirect: cloudera.exe.node_exporter

roles/node_exporter/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# node_exporter
2+
3+
Install Node Exporter.
4+
5+
This role handles the download, installation, and configuration of the Prometheus Node Exporter on a Linux host. It ensures the Node Exporter is set up as a systemd service, running under a dedicated user and group, making it ready to expose host-level metrics for Prometheus scraping.
6+
7+
The role will:
8+
- Create a dedicated system user and group for the Node Exporter service.
9+
- Download the specified Node Exporter tarball from the provided URL.
10+
- Extract the Node Exporter binary to the configured directory.
11+
- Set up a systemd service file for Node Exporter.
12+
- Enable and start the Node Exporter service, ensuring it runs on system boot.
13+
14+
## Requirements
15+
16+
- Target host must have `systemd` for service management.
17+
- Internet access on the target host to download the Node Exporter tarball.
18+
19+
## Dependencies
20+
21+
None.
22+
23+
## Role Variables
24+
25+
| Parameter | Type | Default Value | Required | Description |
26+
|----------------------------------|------|------------------------------------------------------------------------------------|----------|-------------------------------------------------|
27+
| `node_exporter_directory` | `path`| `/etc/node_exporter` | `false` | The directory where Node Exporter will be installed. |
28+
| `node_exporter_tarball_url` | `str`| `https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz`| `false` | URL to the Node Exporter installation package (tarball). |
29+
| `node_exporter_tarball_file` | `str`| `node_exporter.tar.gz` | `false` | The intermediate filename to use for the downloaded tarball. |
30+
| `node_exporter_service_directory`| `path`| `/etc/systemd/system/node_exporter.service` | `false` | Full path to the systemd service file for Node Exporter. |
31+
| `node_exporter_user` | `str`| `node_exporter` | `false` | The system username under which the Node Exporter service will run. |
32+
| `node_exporter_group` | `str`| `node_exporter` | `false` | The system group under which the Node Exporter service will run. |
33+
34+
## Examples
35+
36+
```yaml
37+
- name: Install Node Exporter with default configuration
38+
ansible.builtin.import_role:
39+
name: node_exporter
40+
# No variables needed here as defaults will be used
41+
42+
- name: Install Node Exporter v1.8.0
43+
ansible.builtin.import_role:
44+
name: node_exporter
45+
vars:
46+
node_exporter_tarball_url: "https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz"
47+
node_exporter_tarball_file: "node_exporter-1.8.0.tar.gz" # Update filename for clarity
48+
49+
- name: Install Node Exporter with custom paths and user
50+
ansible.builtin.import_role:
51+
name: node_exporter
52+
vars:
53+
node_exporter_directory: "/opt/monitoring/node_exporter"
54+
node_exporter_service_directory: "/usr/lib/systemd/system/node_exporter.service" # Common location on some distros
55+
node_exporter_user: "prometheus_exporter"
56+
node_exporter_group: "prometheus_exporter"
57+
```
58+
59+
## License
60+
61+
```
62+
Copyright 2025 Cloudera, Inc.
63+
64+
Licensed under the Apache License, Version 2.0 (the "License");
65+
you may not use this file except in compliance with the License.
66+
You may obtain a copy of the License at
67+
68+
https://www.apache.org/licenses/LICENSE-2.0
69+
70+
Unless required by applicable law or agreed to in writing, software
71+
distributed under the License is distributed on an "AS IS" BASIS,
72+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
73+
See the License for the specific language governing permissions and
74+
limitations under the License.
75+
```
File renamed without changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
17+
- name: Start node_exporter service
18+
block:
19+
- name: Reload systemd daemon
20+
ansible.builtin.systemd:
21+
daemon_reload: true
22+
23+
- name: Enable and start node_exporter service
24+
ansible.builtin.systemd:
25+
name: node_exporter
26+
state: started
27+
enabled: true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2025 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
17+
argument_specs:
18+
main:
19+
short_description: Install Node Exporter
20+
description:
21+
- Download and install the Node Exporter (node_exporter) for Prometheus.
22+
author: Cloudera Labs
23+
version_added: 5.0.0
24+
options:
25+
node_exporter_directory:
26+
description: Configuration directory
27+
type: path
28+
required: false
29+
default: /etc/node_exporter
30+
node_exporter_tarball_url:
31+
description: URL to the installation package
32+
type: str
33+
required: false
34+
default: https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
35+
node_exporter_tarball_file:
36+
description: The intermediate name of the installation package
37+
type: str
38+
required: false
39+
default: node_exporter.tar.gz
40+
node_exporter_service_directory:
41+
description: systemd services directory
42+
type: path
43+
required: false
44+
default: /etc/systemd/system/node_exporter.service
45+
node_exporter_user:
46+
description: Service username
47+
type: str
48+
required: false
49+
default: node_exporter
50+
node_exporter_group:
51+
description: Service group
52+
type: str
53+
required: false
54+
default: node_exporter
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
---
2-
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
1+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
54
# you may not use this file except in compliance with the License.
@@ -13,18 +12,21 @@
1312
# See the License for the specific language governing permissions and
1413
# limitations under the License.
1514

16-
- name: Create nodexporter group
15+
---
16+
17+
- name: Create nodeexporter group
1718
ansible.builtin.user:
1819
name: "{{ node_exporter_group }}"
1920

20-
- name: Create nodexporter user
21+
- name: Create nodeexporter user
2122
ansible.builtin.user:
2223
name: "{{ node_exporter_user }}"
2324
group: "{{ node_exporter_group }}"
2425

2526
- name: Create node_exporter directory
2627
ansible.builtin.file:
2728
path: "{{ node_exporter_directory }}"
29+
mode: "0755"
2830
state: directory
2931

3032
- name: Create a temporary directory
@@ -36,6 +38,7 @@
3638
ansible.builtin.get_url:
3739
url: "{{ node_exporter_tarball_url }}"
3840
dest: "{{ __exporter_tmp.path }}/{{ node_exporter_tarball_file }}"
41+
mode: "0755"
3942

4043
- name: Extract tarball
4144
ansible.builtin.unarchive:
@@ -46,27 +49,15 @@
4649
group: "{{ node_exporter_group }}"
4750
remote_src: true
4851

49-
- name: Remove the temporary directory
52+
- name: Remove the temporary directory
5053
when: __exporter_tmp is defined
5154
ansible.builtin.file:
5255
path: "{{ __exporter_tmp.path }}"
5356
state: absent
5457

55-
- name: Copy Node Exporter service file
58+
- name: Copy node exporter service file
5659
ansible.builtin.template:
5760
src: node_exporter.service.j2
5861
dest: "{{ node_exporter_service_directory }}"
59-
register: __exporter_service
60-
61-
- name: Start and enable node_exporter service
62-
when: __exporter_service.changed
63-
block:
64-
- name: Reload systemd daemon
65-
ansible.builtin.systemd:
66-
daemon_reload: true
67-
68-
- name: Enable and start node_exporter service
69-
ansible.builtin.systemd:
70-
name: node_exporter
71-
state: started
72-
enabled: true
62+
mode: "0755"
63+
notify: Start node_exporter service

roles/nodeexporter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_exporter

roles/nodeexporter/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)