Skip to content
Snippets Groups Projects
Commit faeb8aa8 authored by Jonas Leder's avatar Jonas Leder
Browse files

add mysql exporter install playbook

parent 8ca277a3
Branches
No related tags found
No related merge requests found
[Unit]
Description=MySQL Metrics Exporter for Prometheus
After=network.target
Wants=network-online.target
[Service]
Restart=always
Type=simple
User=mysql
ExecStart=/usr/local/bin/mysqld_exporter
Environment=
[Install]
WantedBy=multi-user.target
\ No newline at end of file
- name: Install Prometheus node exporter
hosts: all
vars:
mysqld_exporter_version: 1.15.1
arch: "{% if ansible_architecture == 'x86_64' %}amd64{% elif ansible_architecture == 'aarch64' %}arm64{% endif %}"
tasks:
- name: uninstall mysqld-exporter package
apt:
name: prometheus-mysqld-exporter
state: absent
purge: yes
autoremove: yes
- name: download mysqld-exporter release
get_url:
url: "https://github.com/prometheus/mysqld_exporter/releases/download/v{{ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ arch }}.tar.gz"
dest: /tmp/mysqld_exporter.tar.gz
- name: extract mysqld-exporter release
unarchive:
src: /tmp/mysqld_exporter.tar.gz
dest: /tmp
remote_src: yes
- name: delete old binary if exists
file:
path: /usr/local/bin/mysqld_exporter
state: absent
- name: move mysqld-exporter binary
shell: cp /tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ arch }}/mysqld_exporter /usr/local/bin/mysqld_exporter
- name: install systemd-service
copy:
src: files/mysqld_exporter.service
dest: /etc/systemd/system/mysqld_exporter.service
mode: 0644
- name: reload systemd
systemd:
daemon_reload: yes
- name: enable mysqld-exporter service
systemd:
name: mysqld_exporter
enabled: yes
state: started
- name: delete temporary files
file:
path: /tmp/mysqld_exporter*
state: absent
- name: check mysqld-exporter status
uri:
url: http://localhost:9104/metrics
status_code: 200
timeout: 5
return_content: yes
register: mysqld_exporter_status
until: mysqld_exporter_status.status == 200
retries: 5
delay: 5
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment