Fix ansible lint

pull/44/head
Emilien Mantel 2021-09-01 13:47:31 +02:00
parent 4f7f8481bc
commit 1f289107ff
8 changed files with 38 additions and 6 deletions

View File

@ -1,6 +1,8 @@
---
galaxy_info:
namespace: hanxhx
role_name: mysql
author: Emilien Mantel
description: Install and configure MariaDB (and Galera Cluster) on Debian
company:

View File

@ -4,6 +4,9 @@
template:
src: etc/mysql/mariadb.conf.d/20-galera.cnf.j2
dest: /etc/mysql/mariadb.conf.d/20-galera.cnf
mode: 0644
owner: root
group: root
register: galeraconfig
- name: INCLUDE | Bootstrap first node

View File

@ -14,6 +14,9 @@
template:
src: etc/apt/preferences.d/95-mariadb.j2
dest: /etc/apt/preferences.d/95-mariadb
mode: 0644
owner: root
group: root
- name: APT_REPOSITORY | Add MariaDB repository
apt_repository:

View File

@ -16,6 +16,10 @@
template:
src: "{{ item }}"
dest: "/{{ item | replace('.j2', '') }}"
mode: 0644
owner: root
group: root
register: config
loop:
- etc/mysql/my.cnf
- etc/mysql/conf.d/mysqldump.cnf.j2
@ -23,7 +27,6 @@
- etc/mysql/mariadb.conf.d/50-client.cnf.j2
- etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf.j2
- etc/mysql/mariadb.conf.d/50-server.cnf.j2
register: config
- name: SERVICE | Restart Mariadb now one at a time (prevent bugs)
throttle: 1

View File

@ -4,4 +4,7 @@
template:
src: etc/mysql/mariadb.conf.d/40-master.cnf.j2
dest: /etc/mysql/mariadb.conf.d/40-master.cnf
mode: 0644
owner: root
group: root
notify: restart mariadb

View File

@ -10,6 +10,9 @@
template:
src: etc/mysql/mariadb.conf.d/40-slave.cnf.j2
dest: /etc/mysql/mariadb.conf.d/40-slave.cnf
mode: 0644
owner: root
group: root
notify: restart mariadb
- name: MYSQL_REPLICATION | Get slave status

View File

@ -23,6 +23,9 @@
file:
path: "{{ mariadb_backup_dir }}"
state: directory
mode: 0755
owner: root
group: root
- name: COMMAND | Prepare backup another server
command: "mariabackup --backup -u root --target-dir={{ mariadb_backup_dir }}"
@ -30,8 +33,8 @@
creates: "{{ mariadb_backup_dir }}/xtrabackup_info"
register: backup
- name: SHELL | Dump
shell: "mariabackup --prepare --target-dir={{ mariadb_backup_dir }}"
- name: COMMAND | Dump
command: "mariabackup --prepare --target-dir={{ mariadb_backup_dir }}"
when: backup.changed
register: prep
changed_when: "'This target seems to be not prepared yet' in prep.stderr"
@ -52,15 +55,17 @@
name: mariadb
state: stopped
# TODO: add an "ignore warning"
- name: COMMAND | Sync backup to slave - TODO remove vagrant as static user (see why mariadb_backup_user is not working)
shell: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_datadir }}/"
command: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_datadir }}/"
become: false
tags:
- skip_ansible_lint
- name: FILE | Re-apply owner
file:
path: "{{ mariadb_datadir }}"
state: directory
mode: 0755
owner: mysql
group: mysql
recurse: true

View File

@ -30,6 +30,9 @@
copy:
src: import1.sql
dest: /tmp/import1.sql
mode: 0644
owner: root
group: root
register: c
- name: MYSQL_DB | Import first dump
@ -40,12 +43,16 @@
login_unix_socket: "{{ mariadb_socket }}"
loop: ['testrepl', 'norepl']
when: c.changed
tags:
- skip_ansible_lint
- hosts: slave
pre_tasks:
- name: SHELL | Get master IP
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
shell: set -o pipefail && getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
args:
executable: /bin/bash
register: ip
changed_when: false
@ -66,6 +73,9 @@
copy:
src: import2.sql
dest: /tmp/import2.sql
mode: 0644
owner: root
group: root
delegate_to: "{{ mariadb_slave_import_from }}"
register: c