diff --git a/meta/main.yml b/meta/main.yml index 0830012..23bc797 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -15,6 +15,7 @@ galaxy_info: - jessie - name: Ubuntu versions: + - trusty - xenial galaxy_tags: - monitoring diff --git a/tasks/main.yml b/tasks/main.yml index 31c14a3..451a188 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -37,10 +37,22 @@ owner: root group: root mode: 0644 + when: ansible_service_mgr == 'systemd' notify: - service reenable - restart node exporter +- name: create init service unit + template: + src: etc/init/prometheus-node-exporter.conf.j2 + dest: /etc/init/prometheus-node-exporter.conf + owner: root + group: root + mode: 0644 + when: ansible_service_mgr == 'upstart' + notify: + - restart node exporter + - name: ensure prometheus node exporter service is enabled service: name: prometheus-node-exporter diff --git a/templates/etc/init/prometheus-node-exporter.conf.j2 b/templates/etc/init/prometheus-node-exporter.conf.j2 new file mode 100644 index 0000000..810c230 --- /dev/null +++ b/templates/etc/init/prometheus-node-exporter.conf.j2 @@ -0,0 +1,14 @@ +description "Prometheus Node Exporter" +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [016] + +respawn +setuid root +setgid {{ prometheus_exporters_common_group }} + +script + exec >> "{{ prometheus_exporters_common_log_dir }}/node-exporter.log" + exec 2>&1 + exec {{ prometheus_exporters_common_root_dir }}/node_exporter_current/node_exporter -collectors.enabled={{ prometheus_node_exporter_enabled_collectors | join(',') }} {% for flag, flag_value in prometheus_node_exporter_config_flags.iteritems() %}-{{ flag }}={{ flag_value }} {% endfor %} + +end script