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_config_file: /etc/munin/plugin-conf.d/zzz-mariadb
munin_sql_user: munin munin_sql_user: munin
munin_sql_password: "{{ lookup('ansible.builtin.password', '/tmp/{{ inventory_hostname }}_munin_sql_password chars=ascii_lowercase,digits length=23') }}" 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 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: mysqld:
slow_query_log: 1 slow_query_log: 1
slowlog_query_log_file: /var/log/mysql/mariadb-slow.logA slowlog_query_log_file: /var/log/mysql/mariadb-slow.logA
slowlog_query_time: 10 slowlog_query_time: 10
slowlog_log_slow_rate_limit: 1000 slowlog_log_slow_rate_limit: 1000
log_slow_verbosity: query_plan 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 name: munin-node
state: restarted state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: restart mariadb - name: restart mariadb
service: service:
name: mariadb name: mariadb
state: restarted state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true

View file

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

View file

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

View file

@ -1,24 +1,5 @@
# {{ ansible_managed }} # {{ ansible_managed }}
DBHOST={{ automysqlbackup_dbhost }} {% for key, value in automysqlbackup_config.items() %}
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 ,\ ` {{ key | upper }}={{ value }}
BACKUPDIR="{{ automysqlbackup_backupdir }}" {% endfor %}
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=""