Repository URL to install this package:
|
Version:
1.0.0b1 ▾
|
---
- include: preflight.yml
- name: Create the MySQL Exporter group
group:
name: "{{ __mysqld_exporter_group }}"
state: present
system: true
- name: Create the MySQL Exporter user
user:
name: "{{ __mysqld_exporter_user }}"
groups: "{{ __mysqld_exporter_group }}"
append: true
shell: /usr/sbin/nologin
system: true
createhome: false
home: /
- name: Download mysqld_exporter binary to local folder
become: false
get_url:
url: "https://github.com/prometheus/mysqld_exporter/releases/download/v{{ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
checksum: "sha256:{{ __mysqld_exporter_checksum }}"
register: _download_binary
until: _download_binary is succeeded
retries: 5
delay: 2
delegate_to: localhost
check_mode: false
- name: Unpack mysqld_exporter binary
become: false
unarchive:
src: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp"
creates: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/mysqld_exporter"
delegate_to: localhost
check_mode: false
- name: Propagate mysqld_exporter binaries
copy:
src: "/tmp/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/mysqld_exporter"
dest: "/usr/local/bin/mysqld_exporter"
mode: 0755
owner: root
group: root
notify:
- restart mysqld exporter
when: not ansible_check_mode
- name: Copy the mysqld_exporter systemd service file
template:
src: mysqld_exporter.service.j2
dest: /etc/systemd/system/mysqld_exporter.service
owner: root
group: root
mode: 0644
no_log: true
notify:
- restart mysqld exporter
- name: Ensure mysqld_exporter is enabled on boot
systemd:
daemon_reload: true
name: mysqld_exporter
enabled: true