Skip to content

Commit

Permalink
make systemd socket activation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
oussamasiyagh committed Mar 1, 2024
1 parent 6b2fb74 commit 2f6c924
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions roles/node_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_exporter_disabled_collectors: []
node_exporter_binary_install_dir: "/usr/local/bin"
node_exporter_system_group: "node-exp"
node_exporter_system_user: "{{ node_exporter_system_group }}"
node_exporter_systemd_socket_activation: false
4 changes: 4 additions & 0 deletions roles/node_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ argument_specs:
- "I(Advanced)"
- "Node exporter user"
default: "node-exp"
node_exporter_systemd_socket_activation:
description:
- "Node exporter systemd socket activation task is executed when set to true."
default: false
1 change: 1 addition & 0 deletions roles/node_exporter/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
group: root
mode: 0644
notify: restart node_exporter
when: node_exporter_systemd_socket_activation

- name: Create node_exporter config directory
ansible.builtin.file:
Expand Down
7 changes: 6 additions & 1 deletion roles/node_exporter/templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
[Unit]
Description=Prometheus Node Exporter
After=network-online.target
{% if node_exporter_systemd_socket_activation %}
Requires=node_exporter.socket
{% endif -%}

[Service]
Type=simple
User={{ node_exporter_system_user }}
Group={{ node_exporter_system_group }}
ExecStart={{ node_exporter_binary_install_dir }}/node_exporter --web.systemd-socket \
ExecStart={{ node_exporter_binary_install_dir }}/node_exporter \
{% if node_exporter_systemd_socket_activation %}
--web.systemd-socket \
{% endif -%}
{% for collector in node_exporter_enabled_collectors -%}
{% if not collector is mapping %}
'--collector.{{ collector }}' \
Expand Down

0 comments on commit 2f6c924

Please sign in to comment.