--- - name: Include OS-specific variables ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" - name: Install packages ansible.builtin.package: name: "{{ node_exporter_package }}" state: installed - name: Allow prometheus user to read private key ansible.builtin.user: name: "{{ node_exporter_user }}" groups: hostkey append: true notify: Restart node_exporter - name: Create config directory ansible.builtin.file: path: /etc/node_exporter state: directory mode: "0755" owner: root group: "{{ ansible_wheel }}" - name: Create web-config ansible.builtin.template: dest: /etc/node_exporter/web-config.yml src: web-config.yml.j2 mode: "0644" owner: root group: "{{ ansible_wheel }}" notify: Restart node_exporter - name: Modify config ansible.builtin.lineinfile: path: /etc/default/prometheus-node-exporter regexp: "^ARGS=" line: >- ARGS="--collector.filesystem.ignored-mount-points '^/(dev|proc|sys|run/(user|credentials/systemd-.+))($|/)' --collector.netclass.ignored-devices '^(br-|docker|veth).+$' --collector.netdev.device-exclude '^(br-|docker|veth).+$' --web.config=/etc/node_exporter/web-config.yml --collector.textfile.directory /var/lib/prometheus/node-exporter" notify: Restart node_exporter when: ansible_os_family == "RedHat" - name: Enable service ansible.builtin.service: name: "{{ node_exporter_service }}" state: started enabled: true arguments: --web.config.file=/etc/node_exporter/web-config.yml when: ansible_os_family == "OpenBSD" - name: Enable service ansible.builtin.service: name: "{{ node_exporter_service }}" state: started enabled: true when: ansible_os_family == "RedHat"