Remove master namming
This commit is contained in:
parent
904a107ae1
commit
a7989e042d
4
Makefile
4
Makefile
|
|
@ -30,9 +30,9 @@ install-pre-commit: ## Install pre-commit tool
|
||||||
$(info --> Install pre-commit tool via `pip3`)
|
$(info --> Install pre-commit tool via `pip3`)
|
||||||
pip3 install pre-commit
|
pip3 install pre-commit
|
||||||
|
|
||||||
pre-commit-run: ## Run pre-commit hooks with $PRE_COMMIT_ARGS default to (diff master...[current_branch])
|
pre-commit-run: ## Run pre-commit hooks
|
||||||
$(info --> run pre-commit on changed files (pre-commit run))
|
$(info --> run pre-commit on changed files (pre-commit run))
|
||||||
pre-commit run $(PRE_COMMIT_ARGS) --color=always
|
pre-commit run --color=always
|
||||||
|
|
||||||
pre-commit-run-all: ## Run pre-commit on the whole repository
|
pre-commit-run-all: ## Run pre-commit on the whole repository
|
||||||
$(info --> run pre-commit on the whole repo (pre-commit run -a))
|
$(info --> run pre-commit on the whole repo (pre-commit run -a))
|
||||||
|
|
|
||||||
20
README.md
20
README.md
|
|
@ -8,7 +8,7 @@ Install and configure MariaDB Server on Debian/Ubuntu.
|
||||||
|
|
||||||
Optionally, this role also permits one to:
|
Optionally, this role also permits one to:
|
||||||
|
|
||||||
- deploy a master/replica cluster;
|
- deploy a primary/replica cluster;
|
||||||
- setup backups and rotation of the dumps.
|
- setup backups and rotation of the dumps.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
@ -214,20 +214,12 @@ See: <https://docs.ansible.com/ansible/latest/modules/mysql_user_module.html>
|
||||||
|
|
||||||
### Replication (optional)
|
### Replication (optional)
|
||||||
|
|
||||||
Replication is only enabled if `mariadb_replication_role` has a value (`master` or
|
Replication is only enabled if `mariadb_replication_role` has a value (`primary` or
|
||||||
`replica`).
|
`replica`).
|
||||||
|
|
||||||
The replication setup on the replica use the GTID autopositioning
|
The replication setup on the replica use the GTID autopositioning, see
|
||||||
`master_use_gtid=slave_pos`. See:
|
|
||||||
<https://mariadb.com/kb/en/library/change-master-to/#master_use_gtid>
|
<https://mariadb.com/kb/en/library/change-master-to/#master_use_gtid>
|
||||||
|
|
||||||
For the moment, we use an `SQL` command but in ansible 2.10, we should be able
|
|
||||||
to use the
|
|
||||||
[`mysql_replication`](https://docs.ansible.com/ansible/latest/modules/mysql_replication_module.html)
|
|
||||||
module (see
|
|
||||||
[`tasks/replication_replica.yml`](./tasks/replication_replica.yml#L09-L33) and
|
|
||||||
<https://github.com/ansible/ansible/pull/62648>).
|
|
||||||
|
|
||||||
#### Common vars
|
#### Common vars
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
@ -236,10 +228,10 @@ module (see
|
||||||
mariadb_replication_user: []
|
mariadb_replication_user: []
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Master variables
|
#### Primary node variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
mariadb_replication_role: master
|
mariadb_replication_role: primary
|
||||||
mariadb_server_id: 1
|
mariadb_server_id: 1
|
||||||
mariadb_max_binlog_size: 100M
|
mariadb_max_binlog_size: 100M
|
||||||
mariadb_binlog_format: MIXED
|
mariadb_binlog_format: MIXED
|
||||||
|
|
@ -251,7 +243,7 @@ mariadb_expire_logs_days: 10
|
||||||
```yaml
|
```yaml
|
||||||
mariadb_replication_role: replica
|
mariadb_replication_role: replica
|
||||||
mariadb_server_id: 1
|
mariadb_server_id: 1
|
||||||
mariadb_replication_master_ip: IP
|
mariadb_replication_primary_ip: IP
|
||||||
```
|
```
|
||||||
|
|
||||||
### Backups (optional)
|
### Backups (optional)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ mariadb_users: []
|
||||||
# Replication
|
# Replication
|
||||||
# replication is only enabled if mariadb_replication_role has values
|
# replication is only enabled if mariadb_replication_role has values
|
||||||
mariadb_replication_role: ""
|
mariadb_replication_role: ""
|
||||||
mariadb_replication_master_ip: ""
|
mariadb_replication_primary_ip: ""
|
||||||
mariadb_max_binlog_size: 100M
|
mariadb_max_binlog_size: 100M
|
||||||
mariadb_binlog_format: MIXED
|
mariadb_binlog_format: MIXED
|
||||||
mariadb_expire_logs_days: 10
|
mariadb_expire_logs_days: 10
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ provisioner:
|
||||||
state: present
|
state: present
|
||||||
replica:
|
replica:
|
||||||
mariadb_replication_role: replica
|
mariadb_replication_role: replica
|
||||||
mariadb_replication_master_ip: node1
|
mariadb_replication_primary_ip: node1
|
||||||
host_vars:
|
host_vars:
|
||||||
node1:
|
node1:
|
||||||
mariadb_server_id: 1
|
mariadb_server_id: 1
|
||||||
mariadb_bind_address: 0.0.0.0
|
mariadb_bind_address: 0.0.0.0
|
||||||
mariadb_replication_role: master
|
mariadb_replication_role: primary
|
||||||
mariadb_max_binlog_size: 100M
|
mariadb_max_binlog_size: 100M
|
||||||
mariadb_binlog_format: MIXED
|
mariadb_binlog_format: MIXED
|
||||||
mariadb_expire_logs_days: 10
|
mariadb_expire_logs_days: 10
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
- name: Verify replication
|
- name: Verify replication
|
||||||
hosts: replica
|
hosts: replica
|
||||||
tasks:
|
tasks:
|
||||||
- name: Check that test db exist (created only on master)
|
- name: Check that test db exist (created only on primary node)
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
mariadb -Bse 'SHOW DATABASES' | grep -q '^{{ item }}$'
|
mariadb -Bse 'SHOW DATABASES' | grep -q '^{{ item }}$'
|
||||||
loop:
|
loop:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
mariadb_server_id: 1
|
mariadb_server_id: 1
|
||||||
mariadb_bind_address: 0.0.0.0
|
mariadb_bind_address: 0.0.0.0
|
||||||
mariadb_replication_role: master
|
mariadb_replication_role: primary
|
||||||
|
|
||||||
mariadb_innodb_raw: |
|
mariadb_innodb_raw: |
|
||||||
innodb_buffer_pool_size = 512M
|
innodb_buffer_pool_size = 512M
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
mariadb_server_id: 1
|
mariadb_server_id: 1
|
||||||
mariadb_bind_address: 0.0.0.0
|
mariadb_bind_address: 0.0.0.0
|
||||||
mariadb_replication_role: master
|
mariadb_replication_role: primary
|
||||||
|
|
||||||
mariadb_innodb_raw: |
|
mariadb_innodb_raw: |
|
||||||
innodb_buffer_pool_size = 512M
|
innodb_buffer_pool_size = 512M
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@
|
||||||
- mariadb_users is defined
|
- mariadb_users is defined
|
||||||
- mariadb_replication_role != "replica"
|
- mariadb_replication_role != "replica"
|
||||||
|
|
||||||
- name: Include task replication_master.yml
|
- name: Include task replication_primary.yml
|
||||||
ansible.builtin.import_tasks: replication_master.yml
|
ansible.builtin.import_tasks: replication_primary.yml
|
||||||
when: mariadb_replication_role == "master"
|
when: mariadb_replication_role == "primary"
|
||||||
|
|
||||||
- name: Include task replication_replica.yml
|
- name: Include task replication_replica.yml
|
||||||
ansible.builtin.import_tasks: replication_replica.yml
|
ansible.builtin.import_tasks: replication_replica.yml
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: Ensure replication user exists on master
|
- name: Ensure replication user exists on primary node
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
host: "{{ item.host | default('%') }}"
|
host: "{{ item.host | default('%') }}"
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
- name: Configure replication on the replica
|
- name: Configure replication on the replica
|
||||||
community.mysql.mysql_replication:
|
community.mysql.mysql_replication:
|
||||||
mode: changeprimary
|
mode: changeprimary
|
||||||
master_host: "{{ mariadb_replication_master_ip }}"
|
primary_host: "{{ mariadb_replication_primary_ip }}"
|
||||||
master_user: "{{ item.name }}"
|
primary_user: "{{ item.name }}"
|
||||||
master_password: "{{ item.password }}"
|
primary_password: "{{ item.password }}"
|
||||||
master_use_gtid: "{{ mariadb_replication_gtid | default('replica_pos') }}"
|
primary_use_gtid: "{{ mariadb_replication_gtid | default('replica_pos') }}"
|
||||||
login_unix_socket: "{{ mariadb_unix_socket }}"
|
login_unix_socket: "{{ mariadb_unix_socket }}"
|
||||||
loop: "{{ mariadb_replication_user }}"
|
loop: "{{ mariadb_replication_user }}"
|
||||||
when:
|
when:
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@
|
||||||
server-id = {{ mariadb_server_id }}
|
server-id = {{ mariadb_server_id }}
|
||||||
log-basename = mariadb
|
log-basename = mariadb
|
||||||
|
|
||||||
{% if mariadb_replication_role == 'master' %}
|
{% if mariadb_replication_role == 'primary' %}
|
||||||
log_bin
|
log_bin
|
||||||
expire_logs_days = {{ mariadb_expire_logs_days }}
|
expire_logs_days = {{ mariadb_expire_logs_days }}
|
||||||
max_binlog_size = {{ mariadb_max_binlog_size }}
|
max_binlog_size = {{ mariadb_max_binlog_size }}
|
||||||
binlog_format = {{mariadb_binlog_format}}
|
binlog_format = {{mariadb_binlog_format}}
|
||||||
# the following permits to simplify the process of moving a replica to a master
|
# the following permits to simplify the process of moving a replica to a
|
||||||
# role by ensuring that replication is not started on master
|
# primary node role by ensuring that replication is not started on primary node
|
||||||
skip-slave-start
|
skip-slave-start
|
||||||
|
|
||||||
{% for db in mariadb_databases %}
|
{% for db in mariadb_databases %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue