prometheus/tasks/exporter/mongodb.yml

71 lines
2.4 KiB
YAML
Raw Normal View History

2021-04-29 18:53:56 +02:00
---
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/percona/mongodb_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
2021-05-27 10:48:47 +02:00
args:
2021-05-27 10:41:33 +02:00
warn: false
2021-05-31 15:42:33 +02:00
register: prometheus_mongodb_exporter_latest_version
run_once: true
2021-05-26 12:01:00 +02:00
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | download'
2021-04-29 18:53:56 +02:00
get_url:
2021-05-31 15:42:33 +02:00
url: https://github.com/percona/mongodb_exporter/releases/download/v{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
2021-04-29 18:53:56 +02:00
dest: /tmp
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | unarchive'
2021-04-29 18:53:56 +02:00
unarchive:
remote_src: yes
2021-05-31 15:42:33 +02:00
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
2021-04-29 18:53:56 +02:00
dest: /tmp
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter < v0.2 | move to /usr/local/bin'
2021-04-29 18:53:56 +02:00
copy:
2021-05-31 15:42:33 +02:00
src: /tmp/mongodb_exporter
2021-04-29 18:53:56 +02:00
dest: /usr/local/bin/prometheus-mongodb-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | mongodb exporter | restart service'
2021-05-31 15:42:33 +02:00
when:
- prometheus_mongodb_exporter_latest_version.stdout < '0.2'
2021-05-31 15:42:33 +02:00
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter > v0.2 | move to /usr/local/bin'
2021-05-31 15:42:33 +02:00
copy:
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64/mongodb_exporter
dest: /usr/local/bin/prometheus-mongodb-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | mongodb exporter | restart service'
when:
- prometheus_mongodb_exporter_latest_version.stdout > '0.2'
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | configuration'
2021-10-29 18:23:10 +02:00
template:
src: conf/prometheus-mongodb-exporter.j2
dest: /etc/default/prometheus-mongodb-exporter
owner: root
group: root
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | install unit file to systemd'
template:
src: systemd/prometheus-mongodb-exporter.service.j2
dest: /etc/systemd/system/prometheus-mongodb-exporter.service
owner: root
group: root
mode: 0600
2021-05-31 12:18:34 +02:00
notify:
- 'prometheus | mongodb exporter | restart service'
2022-11-11 21:08:07 +01:00
- name: 'mongodb exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-mongodb-exporter.service