automysqlbackup configuration via dict

This commit is contained in:
phil 2023-11-04 11:01:20 +01:00
parent 66b59e15f6
commit 4a456923a4
5 changed files with 28 additions and 36 deletions

View file

@ -1,20 +1,31 @@
monit_sql_user: monit
monit_sql_password: "{{ lookup('ansible.builtin.password', '/tmp/{{ inventory_hostname }}_monit_sql_password chars=ascii_lowercase,digits length=23') }}"
munin_sql_config_file: /etc/munin/plugin-conf.d/zzz-mariadb
munin_sql_user: munin
munin_sql_password: "{{ lookup('ansible.builtin.password', '/tmp/{{ inventory_hostname }}_munin_sql_password chars=ascii_lowercase,digits length=23') }}"
mysql_socket: /run/mysqld/mysqld.sock
automysqlbackup_backupdir: /var/lib/automysqlbackup
automysqlbackup_dbhost: localhost
automysqlbackup_mailaddr: root
automysqlbackup_postbackup: /usr/local/bin/automysqlbackup_post_script
mysqld:
slow_query_log: 1
slowlog_query_log_file: /var/log/mysql/mariadb-slow.logA
slowlog_query_time: 10
slowlog_log_slow_rate_limit: 1000
log_slow_verbosity: query_plan
automysqlbackup_config:
dbhost: localhost
dbnames: "$(mysql --defaults-file=/etc/mysql/debian.cnf -s -N --execute='SHOW DATABASES' | grep -v ^mysql$ | grep -v ^performance_schema$ | grep -v ^information_schema$ | xargs)"
backupdir: /var/lib/automysqlbackup
mailcontent: quiet
maxattsize: 4000
mailaddr: root
mdbnames: "mysql $DBNAMES"
create_database: "yes"
sepdir: "yes"
doweekly: 6
domonthly: 1
comp: gzip
compdirect: "yes"
commcomp: "yes"
latest: "no"
postbackup: /usr/local/bin/automysqlbackup_post_script
routines: "yes"

View file

@ -4,11 +4,11 @@
name: munin-node
state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: restart mariadb
service:
name: mariadb
state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true

View file

@ -8,5 +8,5 @@
- name: "Backup | Copy automysqlbackup postbackup script"
ansible.builtin.copy:
src: automysqlbackup_post_script
dest: "{{ automysqlbackup_postbackup }}"
dest: "{{ automysqlbackup_config.postbackup }}"
mode: "0755"

View file

@ -7,7 +7,7 @@
notify: restart mariadb
- name: "Configuration | Copy systemd override"
ansible.builtin.file:
ansible.builtin.copy:
src: systemd/override.conf
dest: /etc/systemd/systemd/mariadb.service.d/
mode: "0644"

View file

@ -1,24 +1,5 @@
# {{ ansible_managed }}
DBHOST={{ automysqlbackup_dbhost }}
DBNAMES=`mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW DATABASES" | awk '{print $1}' | grep -v ^Database$ | grep -v ^mysql$ | grep -v ^performance_schema$ | grep -v ^information_schema$ | tr \\\r\\\n ,\ `
BACKUPDIR="{{ automysqlbackup_backupdir }}"
MAILCONTENT="quiet"
MAXATTSIZE="4000"
MAILADDR="{{ automysqlbackup_mailaddr }}"
MDBNAMES="mysql $DBNAMES"
DBEXCLUDE=""
CREATE_DATABASE=yes
SEPDIR=yes
DOWEEKLY=6
DOMONTHLY=01
COMP=gzip
COMPDIRECT=no
COMMCOMP=no
LATEST=no
MAX_ALLOWED_PACKET=
SOCKET=
PREBACKUP=
POSTBACKUP="{{ automysqlbackup_postbackup }}"
ROUTINES=yes
OPTIONS=""
{% for key, value in automysqlbackup_config.items() %}
{{ key | upper }}={{ value }}
{% endfor %}