48 lines
1.6 KiB
YAML
48 lines
1.6 KiB
YAML
---
|
|
- name: '{{ exporter }} exporter | check if exporter is already install'
|
|
stat:
|
|
path: /usr/local/bin/prometheus-{{ exporter }}-exporter
|
|
register: stat_result
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
- name: '{{ exporter }} exporter | remove old exporter version'
|
|
include_tasks: "cleanup.yml"
|
|
when: stat_result.stat.exists and exporter_upgrade == "yes"
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
- name: '{{ exporter }} exporter | install from origin'
|
|
include_tasks: "origin.yml"
|
|
when: >
|
|
(not stat_result.stat.exists or exporter_upgrade == "yes") and
|
|
prometheus_exporters_sources == "origin"
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
- name: '{{ exporter }} exporter | install from repo'
|
|
include_tasks: "repo.yml"
|
|
when: >
|
|
(not stat_result.stat.exists or exporter_upgrade == "yes") and
|
|
prometheus_exporters_sources == "repo"
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
- name: '{{ exporter }} exporter | systemd | copy unit file'
|
|
template:
|
|
src: systemd/prometheus-{{ exporter }}-exporter.service.j2
|
|
dest: /etc/systemd/system/prometheus-{{ exporter }}-exporter.service
|
|
owner: root
|
|
group: root
|
|
mode: 0600
|
|
notify:
|
|
- '{{ exporter }}-exporter-restart'
|
|
when: not stat_result.stat.exists or exporter_upgrade == "yes"
|
|
ignore_errors: '{{ ansible_check_mode }}'
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
- name: '{{ exporter }} exporter | systemd | enable service'
|
|
systemd:
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
name: prometheus-{{ exporter }}-exporter.service
|
|
ignore_errors: '{{ ansible_check_mode }}'
|
|
when: not stat_result.stat.exists or exporter_upgrade == "yes"
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|