Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

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

requires_ansible: ">=2.10"
requires_ansible: ">=2.15.0"

plugin_routing:
role:
role: # Not yet supported
rdbms.server:
deprecation:
removal_version: 3.0.0
warning_text: Use cloudera.exe.rdbms_server instead of this nested role.
redirect: cloudera.exe.rdbms_server
nodeexporter:
deprecation:
removal_version: 6.0.0
warning_text: Please update references to the renamed role, cloudera.exe.node_exporter
redirect: cloudera.exe.node_exporter
75 changes: 75 additions & 0 deletions roles/node_exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# node_exporter

Install Node Exporter.

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.

The role will:
- Create a dedicated system user and group for the Node Exporter service.
- Download the specified Node Exporter tarball from the provided URL.
- Extract the Node Exporter binary to the configured directory.
- Set up a systemd service file for Node Exporter.
- Enable and start the Node Exporter service, ensuring it runs on system boot.

## Requirements

- Target host must have `systemd` for service management.
- Internet access on the target host to download the Node Exporter tarball.

## Dependencies

None.

## Role Variables

| Parameter | Type | Default Value | Required | Description |
|----------------------------------|------|------------------------------------------------------------------------------------|----------|-------------------------------------------------|
| `node_exporter_directory` | `path`| `/etc/node_exporter` | `false` | The directory where Node Exporter will be installed. |
| `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). |
| `node_exporter_tarball_file` | `str`| `node_exporter.tar.gz` | `false` | The intermediate filename to use for the downloaded tarball. |
| `node_exporter_service_directory`| `path`| `/etc/systemd/system/node_exporter.service` | `false` | Full path to the systemd service file for Node Exporter. |
| `node_exporter_user` | `str`| `node_exporter` | `false` | The system username under which the Node Exporter service will run. |
| `node_exporter_group` | `str`| `node_exporter` | `false` | The system group under which the Node Exporter service will run. |

## Examples

```yaml
- name: Install Node Exporter with default configuration
ansible.builtin.import_role:
name: node_exporter
# No variables needed here as defaults will be used

- name: Install Node Exporter v1.8.0
ansible.builtin.import_role:
name: node_exporter
vars:
node_exporter_tarball_url: "https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz"
node_exporter_tarball_file: "node_exporter-1.8.0.tar.gz" # Update filename for clarity

- name: Install Node Exporter with custom paths and user
ansible.builtin.import_role:
name: node_exporter
vars:
node_exporter_directory: "/opt/monitoring/node_exporter"
node_exporter_service_directory: "/usr/lib/systemd/system/node_exporter.service" # Common location on some distros
node_exporter_user: "prometheus_exporter"
node_exporter_group: "prometheus_exporter"
```

## License

```
Copyright 2025 Cloudera, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
27 changes: 27 additions & 0 deletions roles/node_exporter/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Start node_exporter service
block:
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true

- name: Enable and start node_exporter service
ansible.builtin.systemd:
name: node_exporter
state: started
enabled: true
54 changes: 54 additions & 0 deletions roles/node_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2025 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

argument_specs:
main:
short_description: Install Node Exporter
description:
- Download and install the Node Exporter (node_exporter) for Prometheus.
author: Cloudera Labs
version_added: 5.0.0
options:
node_exporter_directory:
description: Configuration directory
type: path
required: false
default: /etc/node_exporter
node_exporter_tarball_url:
description: URL to the installation package
type: str
required: false
default: https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
node_exporter_tarball_file:
description: The intermediate name of the installation package
type: str
required: false
default: node_exporter.tar.gz
node_exporter_service_directory:
description: systemd services directory
type: path
required: false
default: /etc/systemd/system/node_exporter.service
node_exporter_user:
description: Service username
type: str
required: false
default: node_exporter
node_exporter_group:
description: Service group
type: str
required: false
default: node_exporter
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,18 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Create nodexporter group
---

- name: Create nodeexporter group
ansible.builtin.user:
name: "{{ node_exporter_group }}"

- name: Create nodexporter user
- name: Create nodeexporter user
ansible.builtin.user:
name: "{{ node_exporter_user }}"
group: "{{ node_exporter_group }}"

- name: Create node_exporter directory
ansible.builtin.file:
path: "{{ node_exporter_directory }}"
mode: "0755"
state: directory

- name: Create a temporary directory
Expand All @@ -36,6 +38,7 @@
ansible.builtin.get_url:
url: "{{ node_exporter_tarball_url }}"
dest: "{{ __exporter_tmp.path }}/{{ node_exporter_tarball_file }}"
mode: "0755"

- name: Extract tarball
ansible.builtin.unarchive:
Expand All @@ -46,27 +49,15 @@
group: "{{ node_exporter_group }}"
remote_src: true

- name: Remove the temporary directory
- name: Remove the temporary directory
when: __exporter_tmp is defined
ansible.builtin.file:
path: "{{ __exporter_tmp.path }}"
state: absent

- name: Copy Node Exporter service file
- name: Copy node exporter service file
ansible.builtin.template:
src: node_exporter.service.j2
dest: "{{ node_exporter_service_directory }}"
register: __exporter_service

- name: Start and enable node_exporter service
when: __exporter_service.changed
block:
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true

- name: Enable and start node_exporter service
ansible.builtin.systemd:
name: node_exporter
state: started
enabled: true
mode: "0755"
notify: Start node_exporter service
1 change: 1 addition & 0 deletions roles/nodeexporter
17 changes: 0 additions & 17 deletions roles/nodeexporter/README.md

This file was deleted.

Loading