ansible-collection-prometheus/roles/mysqld_exporter/tasks/configure.yml
SuperQ af8fc8fd9e
feat: Add mysqld_exporter role
Add a role for deploying the mysqld_exporter.

Signed-off-by: SuperQ <superq@gmail.com>
2023-03-13 21:08:38 +01:00

51 lines
1.5 KiB
YAML

---
- 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
mode: 0644
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
group: root
mode: 0644
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
group: root
mode: 0644
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"