Ansible roles by Evolix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
ansible-roles/mysql/tasks/munin.yml

109 lines
3.0 KiB

---
- name: is Munin present ?
stat:
path: /etc/munin/plugin-conf.d/munin-node
check_mode: no
register: munin_node_plugins_config
tags:
- mysql
- munin
- block:
- name: "Install perl libraries for Munin (Debian < 11)"
apt:
name:
- libdbd-mysql-perl
- libcache-cache-perl
state: present
when: ansible_distribution_major_version is version('11', '<')
- name: "Install perl libraries for Munin (Debian >= 11)"
apt:
name:
- libcache-cache-perl
- libdbd-mariadb-perl
when: ansible_distribution_major_version is version('11', '>=')
- name: Enable core Munin plugins
file:
src: '/usr/share/munin/plugins/{{ item }}'
dest: /etc/munin/plugins/{{ item }}
state: link
loop:
- mysql_bytes
- mysql_queries
- mysql_slowqueries
- mysql_threads
notify: restart munin-node
- name: Enable contributed Munin plugins
file:
src: /usr/share/munin/plugins/mysql_
dest: '/etc/munin/plugins/mysql_{{ item }}'
state: link
loop:
- commands
- connections
- files_tables
- innodb_bpool
- innodb_bpool_act
- innodb_insert_buf
- innodb_io
- innodb_io_pend
- innodb_log
- innodb_rows
- innodb_semaphores
- myisam_indexes
- network_traffic
- qcache
- qcache_mem
- select_types
- slow
- sorts
- table_locks
- tmp_tables
- replication
notify: restart munin-node
- name: verify Munin configuration for mysql < Debian 11
replace:
dest: /etc/munin/plugin-conf.d/munin-node
after: '\[mysql\*\]'
regexp: '^env.mysqluser (.+)$'
replace: 'env.mysqluser debian-sys-maint'
notify: restart munin-node
when: ansible_distribution_major_version is version_compare('11', '<')
- name: set Munin env.mysqluser option for mysql >= Debian 11
replace:
dest: /etc/munin/plugin-conf.d/munin-node
after: '\[mysql\*\]'
regexp: '^env.mysqluser (.+)$'
replace: 'env.mysqluser root'
notify: restart munin-node
when: ansible_distribution_major_version is version_compare('11', '>=')
- name: set Munin env.mysqlopts option for mysql >= Debian 11
replace:
dest: /etc/munin/plugin-conf.d/munin-node
after: '\[mysql\*\]'
regexp: '^env.mysqlopts (.+)$'
replace: 'env.mysqlopts --defaults-file=/root/.my.cnf'
notify: restart munin-node
when: ansible_distribution_major_version is version_compare('11', '>=')
- name: set Munin env.mysqlconnection option for mysql >= Debian 11
replace:
dest: /etc/munin/plugin-conf.d/munin-node
after: '\[mysql\*\]'
regexp: '^env.mysqlconnection (.+)$'
replace: 'env.mysqlconnection DBI:mysql:mysql;mysql_read_default_file=/root/.my.cnf'
notify: restart munin-node
when: ansible_distribution_major_version is version_compare('11', '>=')
when: munin_node_plugins_config.stat.exists
tags:
- mysql
- munin