2021-04-29 18:53:56 +02:00
|
|
|
|
---
|
2021-05-26 18:23:12 +02:00
|
|
|
|
- name: 'prometheus | mysqld exporter | get latest release from GitHub'
|
|
|
|
|
shell: curl --silent "https://api.github.com/repos/prometheus/mysqld_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_mysqld_exporter_latest_version
|
2021-05-26 18:23:12 +02:00
|
|
|
|
run_once: true
|
2021-05-26 12:01:00 +02:00
|
|
|
|
|
2021-04-29 18:53:56 +02:00
|
|
|
|
- name: 'prometheus | mysqld exporter | download'
|
|
|
|
|
get_url:
|
2021-05-31 15:42:33 +02:00
|
|
|
|
url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version.|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
2021-04-29 18:53:56 +02:00
|
|
|
|
dest: /tmp
|
|
|
|
|
|
|
|
|
|
- name: 'prometheus | mysqld exporter | unarchive'
|
|
|
|
|
unarchive:
|
|
|
|
|
remote_src: yes
|
2021-05-31 15:42:33 +02:00
|
|
|
|
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
2021-04-29 18:53:56 +02:00
|
|
|
|
dest: /tmp
|
|
|
|
|
|
|
|
|
|
- name: 'prometheus | mysqld exporter | move to /usr/local/bin'
|
|
|
|
|
copy:
|
2021-05-31 15:42:33 +02:00
|
|
|
|
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64/mysqld_exporter
|
2021-04-29 18:53:56 +02:00
|
|
|
|
dest: /usr/local/bin/prometheus-mysqld-exporter
|
|
|
|
|
remote_src: yes
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: 0755
|
2021-05-26 18:23:12 +02:00
|
|
|
|
notify:
|
|
|
|
|
- 'prometheus | mysqld exporter | restart service'
|
|
|
|
|
|
|
|
|
|
- name: 'prometheus | mysqld exporter | install unit file to systemd'
|
|
|
|
|
template:
|
|
|
|
|
src: systemd/prometheus-mysqld-exporter.service.j2
|
|
|
|
|
dest: /etc/systemd/system/prometheus-mysqld-exporter.service
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
|
|
- name: 'prometheus | mysqld exporter | configure systemd to use service'
|
|
|
|
|
systemd:
|
|
|
|
|
daemon_reload: yes
|
|
|
|
|
enabled: yes
|
|
|
|
|
name: prometheus-mysqld-exporter.service
|
2021-04-29 18:53:56 +02:00
|
|
|
|
|
2021-05-27 10:53:56 +02:00
|
|
|
|
- name: 'prometheus | mysqld exporter | create configuration directory'
|
|
|
|
|
file:
|
|
|
|
|
path: /var/lib/prometheus
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
|
|
|
|
tags:
|
|
|
|
|
- prometheus
|
|
|
|
|
|
2021-04-29 18:53:56 +02:00
|
|
|
|
- name: 'prometheus | mysqld exporter | configuration'
|
|
|
|
|
copy:
|
|
|
|
|
dest: '/var/lib/prometheus/.my.cnf'
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
mode: 0644
|
|
|
|
|
backup: yes
|
|
|
|
|
content: |
|
|
|
|
|
[client]
|
|
|
|
|
user={{ prometheus_mysqld_exporter_user }}
|
|
|
|
|
password={{ prometheus_mysqld_exporter_password }}
|
2021-05-26 18:23:12 +02:00
|
|
|
|
when:
|
2021-04-29 18:53:56 +02:00
|
|
|
|
- prometheus_mysqld_exporter_user is defined
|
|
|
|
|
register: prometheus_mysqld_exporter_configuration
|
2021-05-26 12:01:00 +02:00
|
|
|
|
notify:
|
|
|
|
|
- 'prometheus | mysqld exporter | restart service'
|