2023-03-05 11:37:44 +00:00
|
|
|
---
|
|
|
|
- name: Copy the mysqld_exporter systemd service file
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: mysqld_exporter.service.j2
|
|
|
|
dest: /etc/systemd/system/mysqld_exporter.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
2023-07-29 08:31:08 +00:00
|
|
|
mode: '0644'
|
2023-03-05 11:37:44 +00:00
|
|
|
notify: restart mysqld_exporter
|
|
|
|
|
|
|
|
- name: Create mysqld_exporter config directory
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ mysqld_exporter_config_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u+rwX,g+rwX,o=rX
|
|
|
|
|
|
|
|
- name: Copy the mysqld_exporter config file
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: my_cnf.j2
|
|
|
|
dest: "{{ mysqld_exporter_config_dir }}/{{ mysqld_exporter_config_file }}"
|
|
|
|
owner: root
|
2023-07-28 07:53:31 +00:00
|
|
|
group: '{{ mysqld_exporter_system_group }}'
|
|
|
|
mode: '0640'
|
2023-03-16 07:57:39 +00:00
|
|
|
no_log: "{{ 'false' if lookup('env', 'CI') else 'true' }}"
|
2023-03-05 11:37:44 +00:00
|
|
|
notify: restart mysqld_exporter
|
|
|
|
|
|
|
|
- name: Configure mysqld_exporter web config
|
|
|
|
when:
|
|
|
|
( mysqld_exporter_tls_server_config | length > 0 ) or
|
|
|
|
( mysqld_exporter_http_server_config | length > 0 ) or
|
|
|
|
( mysqld_exporter_basic_auth_users | length > 0 )
|
|
|
|
block:
|
|
|
|
- name: Copy the mysqld_exporter web config file
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: web_config.yaml.j2
|
|
|
|
dest: "{{ mysqld_exporter_config_dir }}/web_config.yaml"
|
|
|
|
owner: root
|
2023-07-28 07:53:31 +00:00
|
|
|
group: '{{ mysqld_exporter_system_group }}'
|
|
|
|
mode: '0640'
|
2023-03-05 11:37:44 +00:00
|
|
|
notify: restart mysqld_exporter
|
|
|
|
|
|
|
|
- name: Allow mysqld_exporter port in SELinux on RedHat OS family
|
|
|
|
community.general.seport:
|
|
|
|
ports: "{{ mysqld_exporter_web_listen_address.split(':')[-1] }}"
|
|
|
|
proto: tcp
|
|
|
|
setype: http_port_t
|
|
|
|
state: present
|
|
|
|
when:
|
|
|
|
- ansible_version.full is version_compare('2.4', '>=')
|
|
|
|
- ansible_selinux.status == "enabled"
|