2024-12-16 14:42:53 +00:00
|
|
|
- name: Ensure Install requirements for MariaDB repository setup script
|
|
|
|
apt:
|
|
|
|
name: "{{ mariadb_requeriments }}"
|
|
|
|
state: present
|
|
|
|
install_recommends: no
|
|
|
|
|
|
|
|
- name: Download MariaDB repository setup script
|
|
|
|
get_url:
|
|
|
|
url: "https://r.mariadb.com/downloads/mariadb_repo_setup"
|
|
|
|
dest: "/tmp/mariadb_repo_setup"
|
2024-12-17 11:53:59 +00:00
|
|
|
mode: "u=rwx,g=rx,o=rx"
|
2024-12-16 14:42:53 +00:00
|
|
|
|
|
|
|
- name: Run MariaDB repository setup script
|
|
|
|
command:
|
|
|
|
cmd: "/bin/bash /tmp/mariadb_repo_setup --mariadb-server-version=10.11.10"
|
|
|
|
creates: "/etc/apt/sources.list.d/mariadb.list"
|
|
|
|
|
2024-12-17 11:53:59 +00:00
|
|
|
- name: Download Percona repository package
|
|
|
|
get_url:
|
|
|
|
url: "https://repo.percona.com/apt/percona-release_latest.generic_all.deb"
|
|
|
|
dest: "/tmp/percona-release_latest.generic_all.deb"
|
|
|
|
mode: "u=rw,g=r,o=r"
|
|
|
|
|
|
|
|
- name: Install Percona repository package
|
|
|
|
apt:
|
|
|
|
deb: "/tmp/percona-release_latest.generic_all.deb"
|
|
|
|
state: present
|
|
|
|
install_recommends: no
|
|
|
|
|
2024-11-28 12:26:02 +00:00
|
|
|
- name: Install MariaDB packages
|
|
|
|
apt:
|
2024-12-16 14:42:53 +00:00
|
|
|
name: "{{ mariadb_base_packages }}"
|
2024-11-28 12:26:02 +00:00
|
|
|
state: present
|
2024-12-16 14:42:53 +00:00
|
|
|
install_recommends: no
|
|
|
|
|
2024-12-11 11:04:37 +00:00
|
|
|
- name: Ensure required directories exist
|
2024-12-11 09:54:04 +00:00
|
|
|
file:
|
2024-12-11 11:04:37 +00:00
|
|
|
path: "{{ item.path }}"
|
2024-12-11 09:54:04 +00:00
|
|
|
state: directory
|
2024-12-11 11:04:37 +00:00
|
|
|
owner: "{{ item.owner }}"
|
|
|
|
group: "{{ item.group }}"
|
|
|
|
mode: "{{ item.mode }}"
|
2024-12-17 11:53:59 +00:00
|
|
|
loop: "{{ required_directories }}"
|
2024-12-16 14:42:53 +00:00
|
|
|
|
2024-12-17 11:53:59 +00:00
|
|
|
- name: Ensure required custom and Mariabackup files are copied to their destinations and root scripts
|
2024-11-28 12:26:02 +00:00
|
|
|
copy:
|
2024-12-16 14:42:53 +00:00
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
2024-11-28 12:26:02 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
2024-12-16 14:42:53 +00:00
|
|
|
mode: "{{ item.mode }}"
|
2024-12-17 11:53:59 +00:00
|
|
|
loop: "{{ required_files_and_mariabackup_files_and_root_scripts }}"
|
2024-12-16 14:42:53 +00:00
|
|
|
notify: reload systemd
|
|
|
|
|
|
|
|
- name: Add tmpfs in /etc/fstab
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/fstab
|
|
|
|
marker: "# {mark} ANSIBLE-MANAGED TMPFS ENTRY"
|
|
|
|
block: |
|
|
|
|
tmpfs /mnt/mysqltmp tmpfs rw,size=6144M 0 0
|
2024-12-17 11:53:59 +00:00
|
|
|
register: fstab
|
2024-12-16 14:42:53 +00:00
|
|
|
|
|
|
|
- name: Mount all filesystems from /etc/fstab
|
|
|
|
command: mount -a
|
2024-12-17 11:53:59 +00:00
|
|
|
when: fstab.changed
|
2024-12-16 14:42:53 +00:00
|
|
|
|
2024-12-11 12:50:50 +00:00
|
|
|
- name: Set MariaDB Cron to /etc/cron.d
|
|
|
|
template:
|
|
|
|
src: templates/cron_mariadb
|
|
|
|
dest: /etc/cron.d/vn
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
2024-12-16 14:42:53 +00:00
|
|
|
|
2024-12-11 12:50:12 +00:00
|
|
|
- name: Insert MySQL certificates
|
|
|
|
copy:
|
|
|
|
content: "{{ item.content }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: mysql
|
|
|
|
group: mysql
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
loop:
|
|
|
|
- { content: '{{ ca_mysql }}', dest: '/etc/mysql/ca.pem', mode: 'u=rw,g=r,o=r' }
|
|
|
|
- { content: '{{ cert_mysql }}', dest: '/etc/mysql/cert.pem', mode: 'u=rw,g=r,o=r' }
|
|
|
|
- { content: '{{ private_mysql }}', dest: '/etc/mysql/key.pem', mode: 'u=rw,g=,o=' }
|
2024-12-16 14:42:53 +00:00
|
|
|
notify: restart-mariadb
|
|
|
|
|
|
|
|
- name: Set MariaDB custom configuration
|
|
|
|
copy:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: /etc/mysql/mariadb.conf.d/
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
with_fileglob:
|
|
|
|
- "files/z9*.cnf"
|
|
|
|
notify: restart-mariadb
|