Refs #8140: MariaDB Server Deploy - Role WIP
This commit is contained in:
parent
2cf5358d61
commit
a58386259c
|
@ -1,2 +1,6 @@
|
||||||
|
mariadb_base_packages:
|
||||||
|
- mariadb-server
|
||||||
|
- mariadb-backup
|
||||||
|
mariadb_requeriments:
|
||||||
|
- curl
|
||||||
|
- apt-transport-https
|
|
@ -1,3 +1,4 @@
|
||||||
[Service]
|
[Service]
|
||||||
LimitNOFILE=600000
|
LimitNOFILE=600000
|
||||||
LimitMEMLOCK=2M
|
LimitMEMLOCK=2M
|
||||||
|
LimitNOFILE=81035
|
|
@ -116,5 +116,4 @@ performance_schema = ON
|
||||||
performance_schema_digests_size = 20000
|
performance_schema_digests_size = 20000
|
||||||
performance-schema-consumer-events-statements-history = ON
|
performance-schema-consumer-events-statements-history = ON
|
||||||
performance_schema_consumer_events_statements_history_long = ON
|
performance_schema_consumer_events_statements_history_long = ON
|
||||||
query_response_time_stats = ON
|
|
||||||
userstat = ON
|
userstat = ON
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: chrony
|
name: chrony
|
||||||
state: restarted
|
state: restarted
|
||||||
- name: restart-mariadb
|
|
||||||
systemd:
|
|
||||||
name: mariadb
|
|
||||||
- name: reload systemd
|
- name: reload systemd
|
||||||
command:
|
command:
|
||||||
cmd: systemctl daemon-reload
|
cmd: systemctl daemon-reload
|
||||||
|
- name: restart-mariadb
|
||||||
|
systemd:
|
||||||
|
name: mariadb
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,29 @@
|
||||||
|
# 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
|
- name: Install MariaDB packages
|
||||||
apt:
|
apt:
|
||||||
name: mariadb-server
|
name: "{{ mariadb_base_packages }}"
|
||||||
state: present
|
state: present
|
||||||
#install_recommends: no
|
install_recommends: no
|
||||||
|
|
||||||
- name: Ensure required directories exist
|
- name: Ensure required directories exist
|
||||||
file:
|
file:
|
||||||
path: "{{ item.path }}"
|
path: "{{ item.path }}"
|
||||||
|
@ -11,33 +32,16 @@
|
||||||
group: "{{ item.group }}"
|
group: "{{ item.group }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
loop:
|
loop:
|
||||||
- { path: /var/log/mysql, owner: mysql, group: adm, mode: 'u=rwx,g=rxs,o=' }
|
- { path: /mnt/local-backup, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
|
||||||
- { path: /root/scripts, 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/mysqlbin, 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' }
|
|
||||||
- { path: /mnt/mysqltmp, owner: root, group: root, mode: 'u=rwx,g=rwx,o=rwxt' }
|
- { 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: /mnt/mysqlbin/binlog, owner: mysql, group: mysql, mode: 'u=rwx,g=,o=' }
|
||||||
- name: Set MariaDB custom configuration
|
- { path: /var/log/mysql, owner: mysql, group: adm, mode: 'u=rwx,g=rxs,o=' }
|
||||||
copy:
|
- { path: /root/scripts, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx'}
|
||||||
src: "{{ item }}"
|
- { path: /etc/systemd/system/mariadb.service.d, owner: root, group: root, mode: 'u=rwx,g=rx,o=rx' }
|
||||||
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
|
|
||||||
- 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: Ensure required files are copied to their destinations
|
- name: Ensure required files are copied to their destinations
|
||||||
ansible.builtin.copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -47,8 +51,29 @@
|
||||||
- { src: 'files/scripts/README.md', dest: '/root/scripts/README.md', mode: 'u=rw,g=r,o=r' }
|
- { 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: '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' }
|
- { src: 'files/scripts/mysqltuner.pl', dest: '/root/scripts/mysqltuner.pl', mode: 'u=rwx,g=rx,o=rx' }
|
||||||
notify:
|
notify: reload systemd
|
||||||
- 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
|
- name: Set MariaDB Cron to /etc/cron.d
|
||||||
template:
|
template:
|
||||||
src: templates/cron_mariadb
|
src: templates/cron_mariadb
|
||||||
|
@ -56,12 +81,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
- 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: Insert MySQL certificates
|
- name: Insert MySQL certificates
|
||||||
copy:
|
copy:
|
||||||
content: "{{ item.content }}"
|
content: "{{ item.content }}"
|
||||||
|
@ -73,3 +93,15 @@
|
||||||
- { content: '{{ ca_mysql }}', dest: '/etc/mysql/ca.pem', mode: 'u=rw,g=r,o=r' }
|
- { 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: '{{ 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=' }
|
- { 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
|
Loading…
Reference in New Issue