--- - name: generate apt pin file for exporter-node package when: prometheus_exporter_node_version is defined copy: dest: "/etc/apt/preferences.d/prom-exporter-node.pref" content: | Package: prom-exporter-node Pin: version {{ prometheus_exporter_node_version }}-1 Pin-Priority: 1001 - name: remove apt pin file for exporter-node package when: prometheus_exporter_node_version is not defined file: path: "/etc/apt/preferences.d/prom-exporter-node.pref" state: absent - name: install apt packages apt: name: - "prom-exporter-node{% if prometheus_exporter_node_version is defined %}={{ prometheus_exporter_node_version }}-1{% endif %}" - moreutils state: present allow_downgrade: yes notify: restart prometheus-node-exporter - name: create directory for textfile collector file: path: /var/lib/prometheus-node-exporter/textfile-collector state: directory - name: generate systemd service unit template: src: service.j2 dest: /etc/systemd/system/prometheus-node-exporter.service notify: restart prometheus-node-exporter - name: make sure prometheus-node-exporter is enabled and started systemd: name: prometheus-node-exporter.service daemon_reload: yes state: started enabled: yes - name: register exporter copy: content: | location = /node { proxy_pass http://127.0.0.1:9100/metrics; } dest: /etc/prometheus/exporter/node.locations notify: reload nginx - name: install common deps for textfile collector scripts apt: name: "{{ python_basename }}-prometheus-client" state: present - name: create directory for textfile collector scripts file: path: /usr/local/share/prometheus-node-exporter state: directory - name: install the apt_info textfile collector script when: prometheus_exporter_node_install_apt_info_textfile_collector_script vars: textfile_collector_name: "apt_info" include_tasks: textfile_collector_generic.yml - name: install all other textfile collector scripts loop: "{{ prometheus_exporter_node_textfile_collector_scripts }}" loop_control: loop_var: textfile_collector_name include_tasks: "{{ q('first_found', ['textfile_collector_' + textfile_collector_name + '.yml', 'textfile_collector_generic.yml'] ) | first }}"