vn-ansible/roles/services/tasks/mariadb.yml

160 lines
4.1 KiB
YAML
Raw Normal View History

# Review /root/scripts/check-memory.sh --> It's not optimal to do what this program does
# Also review the cron task /root/scripts/scheduler-log.sh
- name: Ensure Install requirements for MariaDB repository setup script
apt:
name: "{{ mariadb_requeriments }}"
state: present
install_recommends: no
- name: Download required setup files
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop: "{{ downloads }}"
- 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"
- name: Install Percona repository package
apt:
deb: "/tmp/percona-release_latest.generic_all.deb"
state: present
install_recommends: no
- name: Install MariaDB packages
apt:
name: "{{ mariadb_base_packages }}"
state: present
install_recommends: no
- name: Ensure required directories exist
file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
loop: "{{ required_directories }}"
- name: Ensure required custom and Mariabackup files are copied to their destinations and root scripts
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
loop: "{{ required_files_and_mariabackup_files_and_root_scripts }}"
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
register: fstab
- name: Mount all filesystems from /etc/fstab
command: mount -a
when: fstab.changed
# - 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
- name: Insert MySQL certificates
copy:
content: "{{ item.content }}"
dest: "{{ item.dest }}"
owner: mysql
group: mysql
mode: "{{ item.mode }}"
loop: "{{ certificates }}"
notify: restart-mariadb
- when: production is true
block:
- name: Set MariaDB custom configuration Production
copy:
src: "{{ item }}"
dest: /etc/mysql/mariadb.conf.d/
owner: root
group: root
mode: u=rw,g=r,o=r
2025-01-22 12:58:05 +00:00
with_items:
- "files/mariaconfigfiles/z90-vn.cnf"
- "files/mariaconfigfiles/z95-production"
notify: restart-mariadb
- name: Reminder to check mount points
debug:
msg: |
Remember to check the following mount points:
- /var/lib/mysql
- /mnt/mysqlbin
- /mnt/local-backup
Make sure they are correctly configured and accessible.
- when: testdb is true
block:
- name: Set MariaDB custom configuration Test
copy:
src: "{{ item }}"
dest: /etc/mysql/mariadb.conf.d/
owner: root
group: root
mode: u=rw,g=r,o=r
2025-01-22 12:58:05 +00:00
with_items:
- "files/mariaconfigfiles/z90-vn.cnf"
- "files/mariaconfigfiles/z92-testing.cnf"
notify: restart-mariadb
# - name: Set MariaBackup custom configuration Test
# template:
# src: "apply.config-test.sh"
# dest: /root/mariabackup/apply.config.sh
# owner: root
# group: root
# mode: u=rw,g=r,o=r
- name: Set MariaBackup custom template configuration Test
template:
src: "{{ item }}"
dest: /root/mariabackup/
owner: root
group: root
mode: u=rw,g=,o=
with_items:
- "test-db/apply.config.sh"
- "my.cnf"
- name: Set MariaDB local configuration file
copy:
src: files/mariabackuptest/apply.sql
dest: /root/mariabackup/
owner: root
group: root
mode: u=rw,g=r,o=r
- name: Reminder to check mount points
debug:
msg: |
Remember to check the following mount points:
- /mnt/mysqltmp
2025-01-22 12:58:05 +00:00
Make sure they are correctly configured and accessible.
- name:
2025-01-22 12:58:05 +00:00
template:
src: templates/z99-local.cnf
dest: /etc/mysql/mariadb.conf.d/
owner: root
group: root
mode: u=rw,g=r,o=r