107 lines
3.5 KiB
YAML
107 lines
3.5 KiB
YAML
# 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
|
|
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"
|
|
mode: "u=rwx,g=rx,o=rx"
|
|
|
|
- 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 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:
|
|
- { 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
|
|
copy:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
owner: root
|
|
group: root
|
|
mode: "{{ item.mode }}"
|
|
loop:
|
|
- { 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
|
|
|
|
- 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
|
|
blockinfile:
|
|
path: /etc/fstab
|
|
marker: "# {mark} ANSIBLE-MANAGED TMPFS ENTRY"
|
|
block: |
|
|
tmpfs /mnt/mysqltmp tmpfs rw,size=6144M 0 0
|
|
|
|
- name: Mount all filesystems from /etc/fstab
|
|
command: mount -a
|
|
#when: ansible_facts.mounts | selectattr('mount', 'equalto', '/mnt/mysqltmp') | list | length == 0
|
|
|
|
- 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:
|
|
- { 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=' }
|
|
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 |