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