--- - name: generate apt pin file for exporter-nftables package when: prometheus_exporter_nftables_version is defined copy: dest: "/etc/apt/preferences.d/prom-exporter-nftables.pref" content: | Package: prom-exporter-nftables Pin: version {{ prometheus_exporter_nftables_version }}-1 Pin-Priority: 1001 - name: remove apt pin file for exporter-nftables package when: prometheus_exporter_nftables_version is not defined file: path: "/etc/apt/preferences.d/prom-exporter-nftables.pref" state: absent - name: install apt packages apt: name: "prom-exporter-nftables{% if prometheus_exporter_nftables_version is defined %}={{ prometheus_exporter_nftables_version }}-1{% endif %}" state: present allow_downgrade: yes notify: restart prometheus-nftables-exporter - name: create config directory file: path: /etc/prometheus/exporter/nftables state: directory - name: generate configuration template: src: config.yml.j2 dest: /etc/prometheus/exporter/nftables/config.yml notify: restart prometheus-nftables-exporter - name: generate systemd service unit template: src: service.j2 dest: /etc/systemd/system/prometheus-nftables-exporter.service notify: restart prometheus-nftables-exporter - name: make sure prometheus-nftables-exporter is enabled and started systemd: name: prometheus-nftables-exporter.service daemon_reload: yes state: started enabled: yes - name: register exporter copy: content: | location = /nftables { proxy_pass http://127.0.0.1:9630/metrics; } dest: /etc/prometheus/exporter/nftables.locations notify: reload nginx