57 lines
1.9 KiB
YAML
57 lines
1.9 KiB
YAML
---
|
|
- name: 'prometheus | mysqld exporter | download'
|
|
get_url:
|
|
url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64.tar.gz
|
|
dest: /tmp
|
|
when: prometheus_mysqld_exporter_enable == "true"
|
|
|
|
- name: 'prometheus | mysqld exporter | unarchive'
|
|
unarchive:
|
|
remote_src: yes
|
|
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64.tar.gz
|
|
dest: /tmp
|
|
when: prometheus_mysqld_exporter_enable == "true"
|
|
|
|
- name: 'prometheus | mysqld exporter | move to /usr/local/bin'
|
|
copy:
|
|
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64/mysqld_exporter
|
|
dest: /usr/local/bin/prometheus-mysqld-exporter
|
|
remote_src: yes
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
when: prometheus_mysqld_exporter_enable == "true"
|
|
|
|
- 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
|
|
- prometheus_mysqld_exporter_enable == "true"
|
|
register: prometheus_mysqld_exporter_configuration
|
|
|
|
- name: 'prometheus | mysqld exporter | install unit file to systemd'
|
|
template:
|
|
src: templates/systemd/prometheus-mysqld-exporter.service.j2
|
|
dest: /etc/systemd/system/prometheus-mysqld-exporter.service
|
|
owner: root
|
|
group: root
|
|
mode: 0600
|
|
when: prometheus_mysqld_exporter_enable == "true"
|
|
|
|
- name: 'prometheus | mysqld exporter | configure systemd to use service'
|
|
systemd:
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
state: started
|
|
name: mysqld_exporter.service
|
|
when: prometheus_mysqld_exporter_enable == "true"
|