prometheus/tasks/postgresql_exporter.yml

62 lines
2.3 KiB
YAML
Raw Normal View History

2021-04-29 18:53:56 +02:00
---
- name: 'prometheus | postgres exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus-community/postgres_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_postgres_exporter_version
run_once: true
2021-05-26 12:01:00 +02:00
2021-04-29 18:53:56 +02:00
- name: 'prometheus | postgres exporter | download'
get_url:
url: https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ prometheus_postgres_exporter_version.stdout }}/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64.tar.gz
2021-04-29 18:53:56 +02:00
dest: /tmp
- name: 'prometheus | postgres exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64.tar.gz
2021-04-29 18:53:56 +02:00
dest: /tmp
- name: 'prometheus | postgres exporter | move to /usr/local/bin'
copy:
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64/postgres_exporter
2021-04-29 18:53:56 +02:00
dest: /usr/local/bin/prometheus-postgres-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | postgres exporter | restart service'
- name: 'prometheus | postgres exporter | install unit file to systemd'
template:
src: systemd/prometheus-postgres-exporter.service.j2
dest: /etc/systemd/system/prometheus-postgres-exporter.service
owner: root
group: root
mode: 0600
- name: 'prometheus | postgres exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
state: started
name: prometheus-postgres-exporter.service
2021-04-29 18:53:56 +02:00
2021-05-26 15:52:55 +02:00
- name: 'prometheus | postgres exporter | configuration'
2021-04-29 18:53:56 +02:00
copy:
dest: '/etc/default/prometheus-postgres-exporter'
owner: root
group: root
mode: 0644
backup: yes
content: |
DATA_SOURCE_NAME='postgresql://{{ prometheus_exporter_postgresql_user }}:{{ prometheus_exporter_postgresql_password }}@{{ prometheus_exporter_postgresql_host }}:{{prometheus_exporter_postgresql_port }}/''
ARGS=''
when:
- prometheus_postgres_exporter_user is defined
- prometheus_postgres_exporter_password is defined
- prometheus_postgres_exporter_host is defined
- prometheus_postgres_exporter_port is defined
register: prometheu_postgres_exporter_configuration
2021-05-26 12:01:00 +02:00
notify:
- 'prometheus | postgres exporter | restart service'