2024-12-18 15:05:29 +00:00
|
|
|
# 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
|
2024-12-17 13:05:05 +00:00
|
|
|
|
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
|
|
|
|
|
2024-12-17 13:28:55 +00:00
|
|
|
- name: Download required setup files
|
2024-12-16 14:42:53 +00:00
|
|
|
get_url:
|
2024-12-17 13:28:55 +00:00
|
|
|
url: "{{ item.url }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
loop: "{{ downloads }}"
|
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: 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 }}"
|
2024-12-18 09:57:39 +00:00
|
|
|
loop: "{{ certificates }}"
|
2024-12-16 14:42:53 +00:00
|
|
|
notify: restart-mariadb
|
|
|
|
|
2024-12-18 10:33:30 +00:00
|
|
|
- name: Configure MySQL master cert
|
|
|
|
copy:
|
|
|
|
content: "{{ lookup(passbolt, 'private_mysql', folder_parent_id=passbolt_folder).description }}"
|
|
|
|
dest: /etc/mysql/key.pem
|
|
|
|
owner: mysql
|
|
|
|
group: mysql
|
|
|
|
mode: u=rw,g=,o=
|
|
|
|
|
2025-01-22 08:32:26 +00:00
|
|
|
- when: production is true
|
|
|
|
block:
|
2025-01-22 09:46:06 +00:00
|
|
|
- name: Set MariaDB custom configuration Production
|
2025-01-22 08:32:26 +00:00
|
|
|
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"
|
2025-01-22 08:32:26 +00:00
|
|
|
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.
|
2024-12-18 15:05:29 +00:00
|
|
|
|
2025-01-22 09:43:59 +00:00
|
|
|
- when: testdb is true
|
2025-01-22 08:32:26 +00:00
|
|
|
block:
|
2025-01-22 09:43:59 +00:00
|
|
|
- name: Set MariaDB custom configuration Test
|
2025-01-22 08:32:26 +00:00
|
|
|
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"
|
2025-01-22 08:32:26 +00:00
|
|
|
notify: restart-mariadb
|
2025-01-24 09:33:40 +00:00
|
|
|
|
|
|
|
# - name: Extracting passwords
|
|
|
|
# no_log: true
|
|
|
|
# set_fact:
|
|
|
|
# jenkins_token: "{{ lookup(passbolt, jenkins_user_name, folder_parent_id=passbolt_folder).password }}"
|
|
|
|
|
|
|
|
# - name: Debug variable
|
|
|
|
# debug:
|
|
|
|
# msg: "{{ jenkins_token }}"
|
|
|
|
|
|
|
|
- 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: Extracting dbusername
|
|
|
|
set_fact:
|
|
|
|
dbusername: "{{ lookup(passbolt, dbuser, folder_parent_id=passbolt_folder).username }}"
|
|
|
|
|
|
|
|
- name: Extracting dbpassword
|
|
|
|
no_log: true
|
|
|
|
set_fact:
|
|
|
|
dbpass: "{{ lookup(passbolt, dbuser, folder_parent_id=passbolt_folder).password }}"
|
|
|
|
|
|
|
|
- name: Extracting MariaBackup UserName
|
|
|
|
set_fact:
|
|
|
|
mariabackupusernametpl: "{{ lookup(passbolt, mariabackupusername, folder_parent_id=passbolt_folder).username }}"
|
|
|
|
|
|
|
|
- name: Extracting MariaBackup Password
|
|
|
|
no_log: true
|
|
|
|
set_fact:
|
|
|
|
mariabackuppasstpl: "{{ lookup(passbolt, mariabackupusername, folder_parent_id=passbolt_folder).password }}"
|
|
|
|
|
|
|
|
- name: Set MariaBackup custom template configuration Test
|
|
|
|
template:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: /root/mariabackup/
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=,o=
|
|
|
|
with_items:
|
|
|
|
- "apply.cnf"
|
|
|
|
- "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
|
2025-01-22 08:32:26 +00:00
|
|
|
|
|
|
|
- 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.
|
|
|
|
|
2025-01-24 09:33:40 +00:00
|
|
|
- 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
|