cloudalchemy.node_exporter
DEPRECATED
This role is no longer maintained. Instead, please use the prometheus-community/ansible collection.
Ansible Role: Node Exporter
Warning
Due to restrictions from galaxy.ansible.com, we had to change the role location to this link and replace -
with _
in the role name. This is a significant change that affects all versions of this role, as Ansible Galaxy does not support redirection. We apologize for any inconvenience.
Description
This role helps you deploy the Prometheus Node Exporter using Ansible.
Requirements
- Ansible version 2.7 or higher (it might work with earlier versions, but this isn't guaranteed)
gnu-tar
on the Mac deployer host: you can install it with (brew install gnu-tar
)passlib
is needed for basic authentication (pip install passlib[bcrypt]
)
Role Variables
All adjustable variables are listed in defaults/main.yml and summarized in the table below.
Name | Default Value | Description |
---|---|---|
node_exporter_version |
1.1.2 | Version of the Node Exporter package. You can also specify 'latest'. |
node_exporter_binary_local_dir |
"" | Use local packages instead of those from GitHub. Specify the directory where node_exporter is stored. This overrides node_exporter_version . |
node_exporter_web_listen_address |
"0.0.0.0:9100" | The address where the Node Exporter will listen. |
node_exporter_web_telemetry_path |
"/metrics" | The path for exposing metrics. |
node_exporter_enabled_collectors |
["systemd",{textfile: {directory: "{{node_exporter_textfile_dir}}"}}] |
List of additional collectors to enable along with their configuration. |
node_exporter_disabled_collectors |
[] | List of collectors to disable (those that Node Exporter disables by default). |
node_exporter_textfile_dir |
"/var/lib/node_exporter" | Directory used by the Textfile Collector. Users must be part of the node-exp system group to have permission to write metrics here. See more details in the TROUBLESHOOTING.md guide. |
node_exporter_tls_server_config |
{} | Configuration for TLS authentication. The structure matches what's in Node Exporter docs. |
node_exporter_http_server_config |
{} | Configuration for HTTP/2 support, structured like in Node Exporter docs. |
node_exporter_basic_auth_users |
{} | Users and passwords for basic authentication. Passwords are hashed automatically. |
Example
Playbook
You can use this role in a playbook like this:
- hosts: all
roles:
- cloudalchemy.node_exporter
TLS Configuration
Before using the Node Exporter role, set up a certificate and key.
- hosts: all
pre_tasks:
- name: Create Node Exporter cert directory
file:
path: "/etc/node_exporter"
state: directory
owner: root
group: root
- name: Create certificate and key
openssl_certificate:
path: /etc/node_exporter/tls.cert
csr_path: /etc/node_exporter/tls.csr
privatekey_path: /etc/node_exporter/tls.key
provider: selfsigned
roles:
- cloudalchemy.node_exporter
vars:
node_exporter_tls_server_config:
cert_file: /etc/node_exporter/tls.cert
key_file: /etc/node_exporter/tls.key
node_exporter_basic_auth_users:
randomuser: examplepassword
Demo Site
An example site demonstrating a complete monitoring solution using Prometheus and Grafana is available on GitHub here, and it's hosted on DigitalOcean.
Local Testing
To test this role locally, the best approach is to use Docker and molecule (v3.x). Make sure Docker is installed. To run your tests, simply use molecule test
.
Continuous Integration
By combining Molecule and CircleCI, we can test how new pull requests will work with different Ansible versions and operating systems. This allows us to create varied test scenarios for different role configurations. Consequently, our test matrix is quite extensive, which may take more time than local testing, so please be patient.
Contributing
Refer to the contributor guideline.
Troubleshooting
See the troubleshooting guide.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Prometheus Node Exporter
ansible-galaxy install cloudalchemy.node_exporter