Ansible linting
This commit is contained in:
parent
c77c79cfa4
commit
ed5a3fbd94
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: restart mariadb
|
- name: restart mariadb
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: mariadb
|
name: mariadb
|
||||||
state: restarted
|
state: restarted
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
- name: Install cron package
|
- name: Install cron package
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
package:
|
package:
|
||||||
- cron
|
- cron
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Deploy DB dump script
|
- name: Deploy DB dump script
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: mariadb_dump_db.sh
|
src: mariadb_dump_db.sh
|
||||||
dest: /usr/local/bin/mariadb_dump_db.sh
|
dest: /usr/local/bin/mariadb_dump_db.sh
|
||||||
owner: root
|
owner: root
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
validate: "bash -n %s"
|
validate: "bash -n %s"
|
||||||
|
|
||||||
- name: Ensure backup dir exists
|
- name: Ensure backup dir exists
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ mariadb_backup_db_dir }}"
|
path: "{{ mariadb_backup_db_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: Deploy crontab file
|
- name: Deploy crontab file
|
||||||
cron:
|
ansible.builtin.cron:
|
||||||
name: "Dump MariaDB databases"
|
name: "Dump MariaDB databases"
|
||||||
minute: "{{ mariadb_backup_db_cron_min }}"
|
minute: "{{ mariadb_backup_db_cron_min }}"
|
||||||
hour: "{{ mariadb_backup_db_cron_hour }}"
|
hour: "{{ mariadb_backup_db_cron_hour }}"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Copy global MariaDB configuration
|
- name: Copy global MariaDB configuration
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: mariadb.cnf.j2
|
src: mariadb.cnf.j2
|
||||||
dest: "{{ mariadb_config_file }}"
|
dest: "{{ mariadb_config_file }}"
|
||||||
owner: root
|
owner: root
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
notify: restart mariadb
|
notify: restart mariadb
|
||||||
|
|
||||||
- name: Create datadir if it does not exist
|
- name: Create datadir if it does not exist
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ mariadb_datadir }}"
|
path: "{{ mariadb_datadir }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: mysql
|
owner: mysql
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: Ensure MariaDB is started and enabled on boot
|
- name: Ensure MariaDB is started and enabled on boot
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: mariadb
|
name: mariadb
|
||||||
state: started
|
state: started
|
||||||
enabled: "{{ mariadb_enabled_on_startup }}"
|
enabled: "{{ mariadb_enabled_on_startup }}"
|
||||||
|
|
||||||
- name: Immediately restart MariaDB (necessary for replication)
|
- name: Immediately restart MariaDB (necessary for replication)
|
||||||
meta: flush_handlers
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Check replica replication status
|
- name: Check replica replication status
|
||||||
mysql_replication:
|
community.mysql.mysql_replication:
|
||||||
mode: getreplica
|
mode: getreplica
|
||||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||||
register: replica
|
register: replica
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
# In ansible 2.10, we should be able to use mysql_replication module.
|
# In ansible 2.10, we should be able to use mysql_replication module.
|
||||||
# See https://github.com/ansible/ansible/pull/62648 (and below)
|
# See https://github.com/ansible/ansible/pull/62648 (and below)
|
||||||
- name: Configure replication on the replica
|
- name: Configure replication on the replica
|
||||||
command: |
|
ansible.builtin.command: |
|
||||||
/usr/bin/mariadb -e "CHANGE MASTER TO master_host='{{ mariadb_replication_master_ip }}',
|
/usr/bin/mariadb -e "CHANGE MASTER TO master_host='{{ mariadb_replication_master_ip }}',
|
||||||
master_user='{{ item.name }}', master_password='{{ item.password }}', master_use_gtid=slave_pos"
|
master_user='{{ item.name }}', master_password='{{ item.password }}', master_use_gtid=slave_pos"
|
||||||
loop: "{{ mariadb_replication_user }}"
|
loop: "{{ mariadb_replication_user }}"
|
||||||
|
|
@ -33,21 +33,21 @@
|
||||||
# no_log: true
|
# no_log: true
|
||||||
|
|
||||||
- name: Reset replica replication
|
- name: Reset replica replication
|
||||||
mysql_replication:
|
community.mysql.mysql_replication:
|
||||||
mode: resetreplica
|
mode: resetreplica
|
||||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||||
when:
|
when:
|
||||||
- not replica.Is_Replica
|
- not replica.Is_Replica
|
||||||
|
|
||||||
- name: Check replica replication status (second time)
|
- name: Check replica replication status (second time)
|
||||||
mysql_replication:
|
community.mysql.mysql_replication:
|
||||||
mode: getreplica
|
mode: getreplica
|
||||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||||
register: replica2
|
register: replica2
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Start replica replication
|
- name: Start replica replication
|
||||||
mysql_replication:
|
community.mysql.mysql_replication:
|
||||||
mode: startreplica
|
mode: startreplica
|
||||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Install mariadb repo necessary packages
|
- name: Install mariadb repo necessary packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
package:
|
package:
|
||||||
- software-properties-common
|
- software-properties-common
|
||||||
- dirmngr
|
- dirmngr
|
||||||
|
|
@ -9,30 +9,30 @@
|
||||||
when: mariadb_use_official_repo
|
when: mariadb_use_official_repo
|
||||||
|
|
||||||
- name: Install mariadb repository key
|
- name: Install mariadb repository key
|
||||||
apt_key:
|
ansible.builtin.apt_key:
|
||||||
keyserver: keyserver.ubuntu.com
|
keyserver: keyserver.ubuntu.com
|
||||||
id: "0xF1656F24C74CD1D8"
|
id: "0xF1656F24C74CD1D8"
|
||||||
when: mariadb_use_official_repo
|
when: mariadb_use_official_repo
|
||||||
|
|
||||||
- name: Setup mariadb repository sourcelist entry
|
- name: Setup mariadb repository sourcelist entry
|
||||||
apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb {{ mariadb_use_official_repo_url }}/{{ mariadb_use_official_repo_version }}/{{ ansible_distribution|lower() }} {{ ansible_distribution_release }} main
|
repo: deb {{ mariadb_use_official_repo_url }}/{{ mariadb_use_official_repo_version }}/{{ ansible_distribution|lower() }} {{ ansible_distribution_release }} main
|
||||||
filename: mariadb
|
filename: mariadb
|
||||||
state: present
|
state: present
|
||||||
when: mariadb_use_official_repo
|
when: mariadb_use_official_repo
|
||||||
|
|
||||||
- name: Install mariadb
|
- name: Install mariadb
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
package:
|
package:
|
||||||
- mariadb-server
|
- mariadb-server
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
- name: Determine required MariaDB Python libraries
|
- name: Determine required MariaDB Python libraries
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
deb_mariadb_python_package: "{% if 'python3' in discovered_interpreter_python|default('') %}python3-pymysql{% else %}python-pymysql{% endif %}"
|
deb_mariadb_python_package: "{% if 'python3' in discovered_interpreter_python|default('') %}python3-pymysql{% else %}python-pymysql{% endif %}"
|
||||||
|
|
||||||
- name: Install python mariadb driver
|
- name: Install python mariadb driver
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ deb_mariadb_python_package }}"
|
name: "{{ deb_mariadb_python_package }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue