🚨 Fix modernized linter

dependabot/pip/requests-2.32.2
Emilien Mantel 2024-08-26 10:12:09 +02:00 committed by Emilien M
parent 28305720f7
commit 4be27557c7
10 changed files with 48 additions and 54 deletions

View File

@ -1,6 +1,6 @@
--- ---
- name: restart mariadb - name: Restart mariadb
ansible.builtin.service: ansible.builtin.service:
name: "{{ mariadb_service_name }}" name: "{{ mariadb_service_name }}"
state: restarted state: restarted

View File

@ -5,9 +5,9 @@ galaxy_info:
role_name: mysql role_name: mysql
author: Emilien Mantel author: Emilien Mantel
description: Install and configure MariaDB (and Galera Cluster) on Debian description: Install and configure MariaDB (and Galera Cluster) on Debian
company: company: TripleStack
license: GPLv2 license: GPLv2
min_ansible_version: 2.11 min_ansible_version: '2.11'
platforms: platforms:
- name: Debian - name: Debian
versions: versions:

View File

@ -8,7 +8,9 @@
path: "{{ __mark }}" path: "{{ __mark }}"
register: s register: s
- block: - name: COMMAND | Setup galera cluster
when: not s.stat.exists or mariadb_galera_resetup
block:
- name: SET_FACT | We must NOT restart after bootstrap! - name: SET_FACT | We must NOT restart after bootstrap!
ansible.builtin.set_fact: ansible.builtin.set_fact:
mariadb_notify_restart: false mariadb_notify_restart: false
@ -21,6 +23,7 @@
- name: COMMAND | Bootstrap first node (systemd) - name: COMMAND | Bootstrap first node (systemd)
ansible.builtin.command: galera_new_cluster ansible.builtin.command: galera_new_cluster
when: ansible_service_mgr == 'systemd' when: ansible_service_mgr == 'systemd'
changed_when: true
- name: SERVICE | Bootstrap first node (clean init) - name: SERVICE | Bootstrap first node (clean init)
ansible.builtin.service: ansible.builtin.service:
@ -30,8 +33,6 @@
register: bootstrap_run register: bootstrap_run
when: ansible_service_mgr != 'systemd' when: ansible_service_mgr != 'systemd'
when: not s.stat.exists or mariadb_galera_resetup
- name: COMMAND | Create Bootstrap mark - name: COMMAND | Create Bootstrap mark
ansible.builtin.command: "touch {{ __mark }}" ansible.builtin.command: "touch {{ __mark }}"
args: args:

View File

@ -11,25 +11,25 @@
register: ondc register: ondc
changed_when: false changed_when: false
- block: - name: BLOCK | Compare debian.cnf
- name: SERVICE | Stop MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: stopped
- name: COPY | Paste primary node's debian.cnf
ansible.builtin.copy:
content: "{{ debiancnf.stdout }}"
dest: /etc/mysql/debian.cnf
mode: 0600
owner: root
group: root
register: paste
- name: SERVICE | Start MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: started
when: debiancnf.stdout != ondc.stdout when: debiancnf.stdout != ondc.stdout
block:
- name: SERVICE | Stop MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: stopped
- name: COPY | Paste primary node's debian.cnf
ansible.builtin.copy:
content: "{{ debiancnf.stdout }}"
dest: /etc/mysql/debian.cnf
mode: 0600
owner: root
group: root
register: paste
- name: SERVICE | Start MariaDB
ansible.builtin.service:
name: "{{ mariadb_service_name }}"
state: started

View File

@ -4,13 +4,15 @@
ansible.builtin.apt: ansible.builtin.apt:
name: gpg name: gpg
- name: COMMAND | Check indempotent - name: COMMAND | Check expected mariadb version
ansible.builtin.command: 'grep -q "{{ mariadb_upstream_version }}" /etc/apt/sources.list.d/mariadb.list' ansible.builtin.command: 'grep -q "{{ mariadb_upstream_version }}" /etc/apt/sources.list.d/mariadb.list'
register: check_idempotent register: check_version
failed_when: false failed_when: false
changed_when: false changed_when: false
- block: - name: APT | Add MariaDB upstream repository
when: check_version.rc > 0
block:
- name: GET_URL | Download MariaDB setup script - name: GET_URL | Download MariaDB setup script
ansible.builtin.get_url: ansible.builtin.get_url:
@ -28,12 +30,3 @@
ansible.builtin.file: ansible.builtin.file:
path: '/tmp/mariadb_repo_setup' path: '/tmp/mariadb_repo_setup'
state: absent state: absent
when: check_idempotent.rc > 0
- name: SHELL | Remove useless old files
ansible.builtin.shell: 'rm -f /etc/apt/sources.list.d/mariadb.list.old_*'
args:
removes: /etc/apt/sources.list.d/mariadb.list.old_1
tags:
- skip_ansible_lint

View File

@ -7,4 +7,4 @@
mode: 0644 mode: 0644
owner: root owner: root
group: root group: root
notify: restart mariadb notify: Restart mariadb

View File

@ -14,11 +14,11 @@
mode: 0644 mode: 0644
owner: root owner: root
group: root group: root
notify: restart mariadb notify: Restart mariadb
- name: MYSQL_REPLICATION | Get slave status - name: MYSQL_REPLICATION | Get slave status
community.mysql.mysql_replication: community.mysql.mysql_replication:
mode: getslave mode: getreplica
login_unix_socket: "{{ mariadb_socket }}" login_unix_socket: "{{ mariadb_socket }}"
ignore_errors: true ignore_errors: true
register: slave_status register: slave_status
@ -33,7 +33,7 @@
- name: MYSQL_REPLICATION | Get slave status - name: MYSQL_REPLICATION | Get slave status
community.mysql.mysql_replication: community.mysql.mysql_replication:
mode: getslave mode: getreplica
login_unix_socket: "{{ mariadb_socket }}" login_unix_socket: "{{ mariadb_socket }}"
ignore_errors: true ignore_errors: true
register: slave_status register: slave_status

View File

@ -7,11 +7,13 @@
mode: 0700 mode: 0700
- name: OPENSSH_KEYPAIR | Create SSH key - name: OPENSSH_KEYPAIR | Create SSH key
openssh_keypair: community.crypto.openssh_keypair:
path: "{{ ansible_env.HOME }}/.ssh/id_rsa" path: "{{ ansible_env.HOME }}/.ssh/id_rsa"
register: gen_ssh register: gen_ssh
- block: - name: BLOCK | Prepare backup
delegate_to: "{{ mariadb_slave_import_from }}"
block:
- name: AUTHORIZED_KEY | Auth slave to backup host - name: AUTHORIZED_KEY | Auth slave to backup host
ansible.posix.authorized_key: ansible.posix.authorized_key:
@ -33,14 +35,12 @@
creates: "{{ mariadb_backup_dir }}/xtrabackup_info" creates: "{{ mariadb_backup_dir }}/xtrabackup_info"
register: backup register: backup
- name: COMMAND | Dump - name: COMMAND | Dump # noqa: no-handler
ansible.builtin.command: "mariabackup --prepare --target-dir={{ mariadb_backup_dir }}" ansible.builtin.command: "mariabackup --prepare --target-dir={{ mariadb_backup_dir }}"
when: backup.changed when: backup.changed
register: prep register: prep
changed_when: "'This target seems to be not prepared yet' in prep.stderr" changed_when: "'This target seems to be not prepared yet' in prep.stderr"
delegate_to: "{{ mariadb_slave_import_from }}"
- name: MYSQL_VARIABLES | Get datadir - name: MYSQL_VARIABLES | Get datadir
community.mysql.mysql_variables: community.mysql.mysql_variables:
variable: datadir variable: datadir

View File

@ -1,12 +1,12 @@
--- ---
- name: MYSQL_REPLICATION | Stop slave - name: MYSQL_REPLICATION | Stop slave
mysql_replication: community.mysql.mysql_replication:
mode: stopslave mode: stopslave
login_unix_socket: "{{ mariadb_socket }}" login_unix_socket: "{{ mariadb_socket }}"
- name: MYSQL_REPLICATION | Configure master host - name: MYSQL_REPLICATION | Configure master host
mysql_replication: community.mysql.mysql_replication:
mode: changemaster mode: changemaster
master_host: "{{ mariadb_replication_host }}" master_host: "{{ mariadb_replication_host }}"
master_port: "{{ mariadb_replication_port }}" master_port: "{{ mariadb_replication_port }}"
@ -16,7 +16,7 @@
no_log: "{{ not mariadb_debug_role }}" no_log: "{{ not mariadb_debug_role }}"
- name: MYSQL_REPLICATION | Change master - name: MYSQL_REPLICATION | Change master
mysql_replication: community.mysql.mysql_replication:
mode: changemaster mode: changemaster
master_log_file: "{{ mariadb_master_log_file }}" master_log_file: "{{ mariadb_master_log_file }}"
master_log_pos: "{{ mariadb_master_log_pos }}" master_log_pos: "{{ mariadb_master_log_pos }}"
@ -24,6 +24,6 @@
when: mariadb_master_log_file is defined and mariadb_master_log_pos is defined when: mariadb_master_log_file is defined and mariadb_master_log_pos is defined
- name: MYSQL_REPLICATION | Start slave - name: MYSQL_REPLICATION | Start slave
mysql_replication: community.mysql.mysql_replication:
mode: startslave mode: startslave
login_unix_socket: "{{ mariadb_socket }}" login_unix_socket: "{{ mariadb_socket }}"

View File

@ -1,7 +1,7 @@
--- ---
- name: MYSQL_USER | Remove all anonymous users - name: MYSQL_USER | Remove all anonymous users
mysql_user: community.mysql.mysql_user:
name: '' name: ''
host: "{{ item }}" host: "{{ item }}"
state: absent state: absent
@ -13,7 +13,7 @@
- localhost - localhost
- name: MYSQL_DB | Remove the test database - name: MYSQL_DB | Remove the test database
mysql_db: community.mysql.mysql_db:
name: test name: test
state: absent state: absent
login_unix_socket: "{{ mariadb_socket }}" login_unix_socket: "{{ mariadb_socket }}"