8343-New-machine-id #48

Merged
xavi merged 40 commits from 8343-New-machine-id into main 2025-01-10 13:29:15 +00:00
2 changed files with 42 additions and 29 deletions
Showing only changes of commit 5cac63b6f0 - Show all commits

View File

@ -1,6 +1,29 @@
mariadb_base_packages: mariadb_base_packages:
- mariadb-server - mariadb-server
- mariadb-backup - mariadb-backup
- pmm2-client
mariadb_requeriments: mariadb_requeriments:
- curl - curl
- apt-transport-https - apt-transport-https
required_directories:
- { path: /mnt/local-backup, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- { path: /mnt/mysqlbin, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- { path: /mnt/mysqltmp, owner: root, group: root, mode: 'u=rwx,g=rwx,o=rwxt' }
- { path: /mnt/mysqlbin/binlog, owner: mysql, group: mysql, mode: 'u=rwx,g=,o=' }
- { path: /root/scripts, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- { path: /root/mariabackup, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
required_files_and_mariabackup_files_and_root_scripts:
- { src: "mariadb_override.conf", dest: "/etc/systemd/system/mariadb.service.d/override.conf", mode: "u=rw,g=r,o=r" }
- { src: "files/mariabackup/bacula-before.sh", dest: "/root/mariabackup/bacula-before.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/mariabackup/config.sh", dest: "/root/mariabackup/config.sh", mode: "u=rwx,g=rx,o=x" }
- { src: "files/mariabackup/inc-backup.sh", dest: "/root/mariabackup/inc-backup.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/mariabackup/my.cnf", dest: "/root/mariabackup/my.cnf", mode: "u=rw,g=,o=" }
- { src: "files/mariabackup/restore-backup.sh", dest: "/root/mariabackup/restore-backup.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/check-memory.sh", dest: "/root/scripts/check-memory.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/export-privs.sh", dest: "/root/scripts/export-privs.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/mysqltuner.pl", dest: "/root/scripts/mysqltuner.pl", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/promote-master.sh", dest: "/root/scripts/promote-master.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/promote-slave.sh", dest: "/root/scripts/promote-slave.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/README.md", dest: "/root/scripts/README.md", mode: "u=rw,g=r,o=r" }
- { src: "files/scripts/scheduler-log.sh", dest: "/root/scripts/scheduler-log.sh", mode: "u=rwx,g=rx,o=rx" }
- { src: "files/scripts/sync-conf.sh", dest: "/root/scripts/sync-conf.sh", mode: "u=rwx,g=rx,o=rx" }

View File

@ -1,6 +1,3 @@
# Percona things pmm2-client https://docs.percona.com/percona-monitoring-and-management/setting-up/client/index.html#package-manager
# Add backup directory custom scripts
- name: Ensure Install requirements for MariaDB repository setup script - name: Ensure Install requirements for MariaDB repository setup script
apt: apt:
name: "{{ mariadb_requeriments }}" name: "{{ mariadb_requeriments }}"
@ -18,6 +15,18 @@
cmd: "/bin/bash /tmp/mariadb_repo_setup --mariadb-server-version=10.11.10" cmd: "/bin/bash /tmp/mariadb_repo_setup --mariadb-server-version=10.11.10"
creates: "/etc/apt/sources.list.d/mariadb.list" creates: "/etc/apt/sources.list.d/mariadb.list"
- 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
- name: Install MariaDB packages - name: Install MariaDB packages
apt: apt:
name: "{{ mariadb_base_packages }}" name: "{{ mariadb_base_packages }}"
@ -31,48 +40,29 @@
owner: "{{ item.owner }}" owner: "{{ item.owner }}"
group: "{{ item.group }}" group: "{{ item.group }}"
mode: "{{ item.mode }}" mode: "{{ item.mode }}"
loop: loop: "{{ required_directories }}"
- { path: /mnt/local-backup, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- { path: /mnt/mysqlbin, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- { path: /mnt/mysqltmp, owner: root, group: root, mode: 'u=rwx,g=rwx,o=rwxt' }
- { path: /mnt/mysqlbin/binlog, owner: mysql, group: mysql, mode: 'u=rwx,g=,o=' }
- { path: /var/log/mysql, owner: mysql, group: adm, mode: 'u=rwx,g=rxs,o=' }
- { path: /root/scripts, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx'}
- { path: /etc/systemd/system/mariadb.service.d, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
- name: Ensure required files are copied to their destinations - name: Ensure required custom and Mariabackup files are copied to their destinations and root scripts
copy: copy:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
owner: root owner: root
group: root group: root
mode: "{{ item.mode }}" mode: "{{ item.mode }}"
loop: loop: "{{ required_files_and_mariabackup_files_and_root_scripts }}"
- { src: 'files/scripts/README.md', dest: '/root/scripts/README.md', mode: 'u=rw,g=r,o=r' }
- { src: 'mariadb_override.conf', dest: '/etc/systemd/system/mariadb.service.d/override.conf', mode: 'u=rw,g=r,o=r' }
- { src: 'files/scripts/mysqltuner.pl', dest: '/root/scripts/mysqltuner.pl', mode: 'u=rwx,g=rx,o=rx' }
notify: reload systemd notify: reload systemd
- name: Set MariaDB custom root scripts
copy:
src: "{{ item }}"
dest: /root/scripts/
owner: root
group: root
mode: u=rwx,g=rx,o=rx
with_fileglob:
- "files/scripts/*.sh"
- name: Add tmpfs in /etc/fstab - name: Add tmpfs in /etc/fstab
blockinfile: blockinfile:
path: /etc/fstab path: /etc/fstab
marker: "# {mark} ANSIBLE-MANAGED TMPFS ENTRY" marker: "# {mark} ANSIBLE-MANAGED TMPFS ENTRY"
block: | block: |
tmpfs /mnt/mysqltmp tmpfs rw,size=6144M 0 0 tmpfs /mnt/mysqltmp tmpfs rw,size=6144M 0 0
register: fstab
- name: Mount all filesystems from /etc/fstab - name: Mount all filesystems from /etc/fstab
command: mount -a command: mount -a
#when: ansible_facts.mounts | selectattr('mount', 'equalto', '/mnt/mysqltmp') | list | length == 0 when: fstab.changed
- name: Set MariaDB Cron to /etc/cron.d - name: Set MariaDB Cron to /etc/cron.d
template: template: