|
|
@ -1,20 +1,28 @@ |
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: set service name |
|
|
|
|
|
|
|
set_fact: mysql_service_name={{ (mysql_engine == 'mysql') | ternary('mysqld','mariadb') }} |
|
|
|
|
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove mariadb repo |
|
|
|
|
|
|
|
file: path=/etc/yum.repos.d/mariadb.repo state=absent |
|
|
|
|
|
|
|
when: mysql_engine == 'mysql' |
|
|
|
|
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- include_vars: "{{ item }}" |
|
|
|
- include_vars: "{{ item }}" |
|
|
|
with_first_found: |
|
|
|
with_first_found: |
|
|
|
- vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml |
|
|
|
- vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml |
|
|
|
- vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml |
|
|
|
- vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml |
|
|
|
- vars/{{ ansible_distribution }}.yml |
|
|
|
- vars/{{ ansible_distribution }}.yml |
|
|
|
- vars/{{ ansible_os_family }}.yml |
|
|
|
- vars/{{ ansible_os_family }}.yml |
|
|
|
- vars/defaults.yml |
|
|
|
|
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Install MariaDB server and client |
|
|
|
- name: Install server and client packages |
|
|
|
package: name={{ mysql_server_packages }} |
|
|
|
package: name={{ mysql_server_packages }} |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy backup scripts |
|
|
|
- name: Deploy backup scripts |
|
|
|
template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/mariadb mode=755 |
|
|
|
template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/mysql mode=755 |
|
|
|
loop: |
|
|
|
loop: |
|
|
|
- pre |
|
|
|
- pre |
|
|
|
- post |
|
|
|
- post |
|
|
@ -25,16 +33,18 @@ |
|
|
|
loop: |
|
|
|
loop: |
|
|
|
- pre.d/mariadb_create_dumps.sh |
|
|
|
- pre.d/mariadb_create_dumps.sh |
|
|
|
- post.d/mariadb_delete_dumps.sh |
|
|
|
- post.d/mariadb_delete_dumps.sh |
|
|
|
|
|
|
|
- pre.d/mariadb |
|
|
|
|
|
|
|
- post.d/mariadb |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Create system override directory |
|
|
|
- name: Create system override directory |
|
|
|
file: path=/etc/systemd/system/mariadb.service.d/ state=directory |
|
|
|
file: path=/etc/systemd/system/{{ mysql_service_name }}.service.d/ state=directory |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Modify the service unit |
|
|
|
- name: Modify the service unit |
|
|
|
template: src=systemd_limits.conf.j2 dest=/etc/systemd/system/mariadb.service.d/limits.conf |
|
|
|
template: src=systemd_limits.conf.j2 dest=/etc/systemd/system/{{ mysql_service_name }}.service.d/limits.conf |
|
|
|
register: mysql_unit |
|
|
|
register: mysql_unit |
|
|
|
notify: restart mariadb |
|
|
|
notify: restart mysql |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Reload systemd |
|
|
|
- name: Reload systemd |
|
|
@ -44,11 +54,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy my.cnf |
|
|
|
- name: Deploy my.cnf |
|
|
|
template: src=my.cnf.j2 dest=/etc/my.cnf |
|
|
|
template: src=my.cnf.j2 dest=/etc/my.cnf |
|
|
|
notify: restart mariadb |
|
|
|
notify: restart mysql |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Start and enable MariaDB |
|
|
|
- name: Start and enable the server |
|
|
|
service: name=mariadb state=started enabled=True |
|
|
|
service: name={{ mysql_service_name }} state=started enabled=True |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Check if we need to create a password for the root user |
|
|
|
- name: Check if we need to create a password for the root user |
|
|
@ -62,7 +72,7 @@ |
|
|
|
when: not my_no_cnf.stat.exists |
|
|
|
when: not my_no_cnf.stat.exists |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Set MariaDB root password |
|
|
|
- name: Set root password |
|
|
|
command: mysqladmin password "{{ my_root_pass.stdout }}" |
|
|
|
command: mysqladmin password "{{ my_root_pass.stdout }}" |
|
|
|
when: |
|
|
|
when: |
|
|
|
- not my_no_cnf.stat.exists |
|
|
|
- not my_no_cnf.stat.exists |
|
|
@ -84,7 +94,7 @@ |
|
|
|
mysql_db: name=test state=absent |
|
|
|
mysql_db: name=test state=absent |
|
|
|
tags: mysql |
|
|
|
tags: mysql |
|
|
|
|
|
|
|
|
|
|
|
- name: Handle MariaDB port |
|
|
|
- name: Handle service port |
|
|
|
iptables_raw: |
|
|
|
iptables_raw: |
|
|
|
name: mysql_port |
|
|
|
name: mysql_port |
|
|
|
state: "{{ (mysql_src_ip is defined and mysql_src_ip | length > 0) | ternary('present','absent') }}" |
|
|
|
state: "{{ (mysql_src_ip is defined and mysql_src_ip | length > 0) | ternary('present','absent') }}" |
|
|
|