darkwizard242.node_exporter

Build Status Ansible Role Ansible Role Ansible Quality Score Quality Gate Status GitHub tag (latest SemVer) GitHub repo size

Ansible Role: Node Exporter

This role installs node_exporter on Debian/Ubuntu and EL systems by default.

Requirements

No specific requirements are needed.

The systemd service for node_exporter sends logs to syslog, and the SyslogIdentifier is set as node_exporter. You can review the logs using the command sudo journalctl -u node_exporter.service. You may also want to set up rsyslog to collect logs from node_exporter and save them to a specific file. For managing log files, use the darkwizard242.logrotate role available on Ansible Galaxy.

Role Variables

Here are the available variables (found in defaults/main.yml):

Variables list:

node_exporter_app: node_exporter
node_exporter_version: 1.5.0
node_exporter_osarch: linux-amd64
node_exporter_archive_format: tar.gz
node_exporter_dl_url: "https://github.com/prometheus/{{ node_exporter_app }}/releases/download/v{{ node_exporter_version }}/{{ node_exporter_app }}-{{ node_exporter_version }}.{{ node_exporter_osarch }}.{{ node_exporter_archive_format }}"

node_exporter_app_group: "{{ node_exporter_app }}"
node_exporter_app_group_desired_state: present

node_exporter_app_user: "{{ node_exporter_app }}"
node_exporter_app_user_desired_state: present
node_exporter_app_user_home_state: no
node_exporter_app_user_shell: /bin/false

node_exporter_temp_path: /tmp

node_exporter_bin_path: /usr/local/bin
node_exporter_bin_path_mode: '0755'
node_exporter_bin_path_remote_src: yes

node_exporter_systemd_service_setup: true
node_exporter_systemd_service_name: "{{ node_exporter_app }}"
node_exporter_systemd_service_flags: --collector.systemd --collector.processes --collector.mountstats
node_exporter_systemd_service_template: "{{ node_exporter_app }}.service.j2"
node_exporter_systemd_service_template_dest: "/etc/systemd/system/{{ node_exporter_app }}.service"
node_exporter_systemd_service_template_user: root
node_exporter_systemd_service_template_group: root
node_exporter_systemd_service_template_dest_mode: '0644'
node_exporter_systemd_service_template_backup: yes
node_exporter_systemd_service_desired_state: restarted
node_exporter_systemd_service_desired_boot_enabled: yes

node_exporter_app_port: 9100
node_exporter_app_check_status_code: 200
node_exporter_app_check_status_code_retries: 10
node_exporter_app_check_status_code_delay: 5

Variables summary:

Variable Description
node_exporter_app Name of the app to install (i.e., node_exporter)
node_exporter_version The version of node_exporter to install, defaults to 1.5.0
node_exporter_osarch Operating system architecture, used for downloading the correct binaries, defaults to linux-amd64
node_exporter_archive_format Format used when downloading the archive.
node_exporter_dl_url URL to download the node_exporter binary from.
node_exporter_app_group The group name for the node_exporter user, defaults to node_exporter.
node_exporter_app_group_desired_state Indicates whether to create the group if it doesn’t exist, use present or absent.
node_exporter_app_user User name that node_exporter will belong to, defaults to node_exporter.
node_exporter_app_user_desired_state Indicates whether to create the user if it doesn’t exist, use present or absent.
node_exporter_app_user_home_state Set to 'no' to avoid creating a home directory for the node_exporter user.
node_exporter_app_user_shell Set to /bin/false since the user does not need a shell.
node_exporter_temp_path Temporary path for downloading and extracting node_exporter.
node_exporter_bin_path Path for the actual node_exporter binary.
node_exporter_bin_path_mode File permissions for the node_exporter binary.
node_exporter_bin_path_remote_src Allows Ansible to handle the unarchive operation on remote hosts.
node_exporter_systemd_service_setup Indicates whether to set up a systemd service file for node_exporter.
node_exporter_systemd_service_name Name of the systemd service file when setup is enabled.
node_exporter_systemd_service_flags Command line flags for the node_exporter service file.
node_exporter_systemd_service_template Jinja2 template filename for the systemd service file.
node_exporter_systemd_service_template_dest Destination filepath for the systemd service when setup is enabled.
node_exporter_systemd_service_template_user Owner of the systemd service file.
node_exporter_systemd_service_template_group Group of the systemd service file.
node_exporter_systemd_service_template_dest_mode Permissions for the systemd service file.
node_exporter_systemd_service_template_backup Back up an existing systemd service file.
node_exporter_systemd_service_desired_state Desired state of the systemd service when setup is enabled.
node_exporter_systemd_service_desired_boot_enabled Enables the node_exporter service at boot time when setup is enabled.
node_exporter_app_port Default port for node_exporter (9100), used to check if it's running.
node_exporter_app_check_status_code Status code to check when monitoring node_exporter.
node_exporter_app_check_status_code_retries Number of retries for checking if node_exporter is running.
node_exporter_app_check_status_code_delay Delay between status checks, in seconds.

Dependencies

No dependencies.

Example Playbook

To install node_exporter with default settings in an Ansible playbook:

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter

To customize the role (e.g., to specify a node_exporter version):

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter
      vars:
        node_exporter_version: 1.0.1

To customize the role (e.g., to disable the systemd service setup):

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter
      vars:
        node_exporter_systemd_service_setup: false

License

MIT

Author Information

This role was created by Ali Muhammad.

Informazioni sul progetto

Installs & configures 'node_exporter' for scraping node metrics.

Installa
ansible-galaxy install darkwizard242.node_exporter
Licenza
mit
Download
5.3k
Proprietario
Senior DevOps/CloudOps Engineer. Dedicated to Automating everything I come across. Love to work on and learn new technologies/tools everyday!