prometheus/tasks/mysqld_exporter.yml
2021-05-27 10:53:56 +02:00

69 lines
2.2 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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//"
args:
warn: false
register: prometheus_mysqld_exporter_version
run_once: true
- name: 'prometheus | mysqld exporter | download'
get_url:
url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version.stdout }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mysqld exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mysqld exporter | move to /usr/local/bin'
copy:
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64/mysqld_exporter
dest: /usr/local/bin/prometheus-mysqld-exporter
remote_src: yes
owner: root
group: root
mode: 0755
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
- name: 'prometheus | mysqld exporter | create configuration directory'
file:
path: /var/lib/prometheus
state: directory
mode: '0755'
tags:
- prometheus
- 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 }}
when:
- prometheus_mysqld_exporter_user is defined
register: prometheus_mysqld_exporter_configuration
notify:
- 'prometheus | mysqld exporter | restart service'