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.
 
 
 
 
 
 

207 lines
4.4 KiB

---
- include_role:
name: remount-usr
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: Scripts directory exists
file:
dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}"
mode: "0700"
state: directory
tags:
- mysql
# mytop
- name: "mytop is installed (jessie)"
apt:
name: mytop
state: present
tags:
- packages
- mytop
- mysql
when: ansible_distribution_release == "jessie"
# - name: "mysql-utilities are installed (Debian 9 or later)"
# apt:
# name: "{{ item }}"
# with_items:
# - mysql-utilities
# when: ansible_distribution_major_version | version_compare('9', '>=')
- name: "mytop dependencies are installed (stretch)"
apt:
name: "{{ item }}"
with_items:
- libconfig-inifiles-perl
- libdbd-mysql-perl
- libdbi-perl
- libterm-readkey-perl
- libtime-hires-perl
tags:
- packages
- mytop
- mysql
when: ansible_distribution_release == "stretch"
- name: "Install depends for mytop (Debian 10 or later)"
apt:
name: "{{ item }}"
with_items:
- mariadb-client-10.3
- libconfig-inifiles-perl
- libterm-readkey-perl
when: ansible_distribution_major_version | version_compare('10', '>=')
- include_role:
name: remount-usr
tags:
- mytop
- mysql
- name: "mytop is installed (Debian 9 or later)"
copy:
src: mytop
dest: /usr/local/bin/mytop
mode: "0755"
owner: root
group: staff
force: yes
tags:
- mytop
- mysql
when: ansible_distribution_major_version | version_compare('9', '>=')
- name: Read debian-sys-maint password
shell: 'cat /etc/mysql/debian.cnf | grep -m1 "password = .*" | cut -d" " -f3'
register: mysql_debian_password
changed_when: False
check_mode: no
tags:
- mytop
- mysql
- name: mytop configuration is copied
template:
src: mytop-config.j2
dest: /root/.mytop
mode: "0600"
force: yes
tags:
- mytop
- mysql
# mysqltuner
- include_role:
name: remount-usr
tags:
- mysql
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: mysqltuner is installed
# copy:
# src: mysqltuner.pl
# dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/mysqltuner.pl"
# mode: "0700"
apt:
name: mysqltuner
state: present
tags:
- mysql
- mysqltuner
- name: aha is installed
apt:
name: aha
tags:
- mysql
# automatic optimizations
- include_role:
name: remount-usr
tags:
- mysql
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: mysql-optimize.sh is installed
copy:
src: mysql-optimize.sh
dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/mysql-optimize.sh"
mode: "0700"
tags:
- mysql
- name: "Cron dir for optimize is present"
file:
path: "/etc/cron.{{ mysql_cron_optimize_frequency | mandatory }}"
state: directory
mode: "0755"
owner: root
group: root
tags:
- mysql
- name: "Enable cron to optimize MySQL"
file:
src: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/mysql-optimize.sh"
dest: /etc/cron.{{ mysql_cron_optimize_frequency | mandatory }}/mysql-optimize.sh
state: link
when: mysql_cron_optimize | bool
tags:
- mysql
- name: "Disable cron to optimize MySQL"
file:
dest: /etc/cron.{{ mysql_cron_optimize_frequency | mandatory }}/mysql-optimize.sh
state: absent
when: not (mysql_cron_optimize | bool)
tags:
- mysql
- name: "Cron dir for mysqltuner is present"
file:
path: "/etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}"
state: directory
mode: "0755"
owner: root
group: root
tags:
- mysql
- mysqltuner
- name: "Enable mysqltuner in cron"
copy:
src: mysqltuner.cron.sh
dest: /etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}/mysqltuner.sh
mode: "0755"
when: mysql_cron_mysqltuner | bool
tags:
- mysql
- mysqltuner
- name: "Disable mysqltuner in cron"
file:
dest: /etc/cron.{{ mysql_cron_mysqltuner_frequency | mandatory }}/mysqltuner.sh
state: absent
when: not (mysql_cron_mysqltuner | bool)
tags:
- mysql
- mysqltuner
# my-add.sh
- include_role:
name: remount-usr
when: (mysql_scripts_dir or general_scripts_dir) | search ("/usr")
- name: Install my-add.sh
copy:
src: my-add.sh
dest: "{{ mysql_scripts_dir or general_scripts_dir | mandatory }}/my-add.sh"
mode: "0700"
tags:
- mysql