From a7989e042dbb8a81df6a3cd1c6e5fab18b9b23b5 Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Wed, 12 Oct 2022 18:51:40 +0200 Subject: [PATCH] Remove master namming --- Makefile | 4 ++-- README.md | 20 ++++++------------- defaults/main.yml | 2 +- molecule/cluster/molecule.yml | 4 ++-- molecule/cluster/verify.yml | 2 +- molecule/default/vars/testvars.yml | 2 +- molecule/vagrant/vars/testvars.yml | 2 +- tasks/main.yml | 6 +++--- ...ion_master.yml => replication_primary.yml} | 2 +- tasks/replication_replica.yml | 8 ++++---- templates/mariadb.cnf.j2 | 6 +++--- 11 files changed, 25 insertions(+), 33 deletions(-) rename tasks/{replication_master.yml => replication_primary.yml} (86%) diff --git a/Makefile b/Makefile index bd9f8f2..a3ac079 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,9 @@ install-pre-commit: ## Install pre-commit tool $(info --> Install pre-commit tool via `pip3`) 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)) - pre-commit run $(PRE_COMMIT_ARGS) --color=always + pre-commit run --color=always pre-commit-run-all: ## Run pre-commit on the whole repository $(info --> run pre-commit on the whole repo (pre-commit run -a)) diff --git a/README.md b/README.md index 502fef2..b74b0ef 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Install and configure MariaDB Server on Debian/Ubuntu. Optionally, this role also permits one to: -- deploy a master/replica cluster; +- deploy a primary/replica cluster; - setup backups and rotation of the dumps. ## Requirements @@ -214,20 +214,12 @@ See: ### 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`). -The replication setup on the replica use the GTID autopositioning -`master_use_gtid=slave_pos`. See: +The replication setup on the replica use the GTID autopositioning, see -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 -). - #### Common vars ```yaml @@ -236,10 +228,10 @@ module (see mariadb_replication_user: [] ``` -#### Master variables +#### Primary node variables ```yaml -mariadb_replication_role: master +mariadb_replication_role: primary mariadb_server_id: 1 mariadb_max_binlog_size: 100M mariadb_binlog_format: MIXED @@ -251,7 +243,7 @@ mariadb_expire_logs_days: 10 ```yaml mariadb_replication_role: replica mariadb_server_id: 1 -mariadb_replication_master_ip: IP +mariadb_replication_primary_ip: IP ``` ### Backups (optional) diff --git a/defaults/main.yml b/defaults/main.yml index 76c56f3..c29f60a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -94,7 +94,7 @@ mariadb_users: [] # Replication # replication is only enabled if mariadb_replication_role has values mariadb_replication_role: "" -mariadb_replication_master_ip: "" +mariadb_replication_primary_ip: "" mariadb_max_binlog_size: 100M mariadb_binlog_format: MIXED mariadb_expire_logs_days: 10 diff --git a/molecule/cluster/molecule.yml b/molecule/cluster/molecule.yml index a69ca07..60126f4 100644 --- a/molecule/cluster/molecule.yml +++ b/molecule/cluster/molecule.yml @@ -38,12 +38,12 @@ provisioner: state: present replica: mariadb_replication_role: replica - mariadb_replication_master_ip: node1 + mariadb_replication_primary_ip: node1 host_vars: node1: mariadb_server_id: 1 mariadb_bind_address: 0.0.0.0 - mariadb_replication_role: master + mariadb_replication_role: primary mariadb_max_binlog_size: 100M mariadb_binlog_format: MIXED mariadb_expire_logs_days: 10 diff --git a/molecule/cluster/verify.yml b/molecule/cluster/verify.yml index 140e116..fe6c3b4 100644 --- a/molecule/cluster/verify.yml +++ b/molecule/cluster/verify.yml @@ -16,7 +16,7 @@ - name: Verify replication hosts: replica 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: | mariadb -Bse 'SHOW DATABASES' | grep -q '^{{ item }}$' loop: diff --git a/molecule/default/vars/testvars.yml b/molecule/default/vars/testvars.yml index 4b64303..9da6440 100644 --- a/molecule/default/vars/testvars.yml +++ b/molecule/default/vars/testvars.yml @@ -1,7 +1,7 @@ --- mariadb_server_id: 1 mariadb_bind_address: 0.0.0.0 -mariadb_replication_role: master +mariadb_replication_role: primary mariadb_innodb_raw: | innodb_buffer_pool_size = 512M diff --git a/molecule/vagrant/vars/testvars.yml b/molecule/vagrant/vars/testvars.yml index 4b64303..9da6440 100644 --- a/molecule/vagrant/vars/testvars.yml +++ b/molecule/vagrant/vars/testvars.yml @@ -1,7 +1,7 @@ --- mariadb_server_id: 1 mariadb_bind_address: 0.0.0.0 -mariadb_replication_role: master +mariadb_replication_role: primary mariadb_innodb_raw: | innodb_buffer_pool_size = 512M diff --git a/tasks/main.yml b/tasks/main.yml index 5bfcac5..4bbd339 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -32,9 +32,9 @@ - mariadb_users is defined - mariadb_replication_role != "replica" -- name: Include task replication_master.yml - ansible.builtin.import_tasks: replication_master.yml - when: mariadb_replication_role == "master" +- name: Include task replication_primary.yml + ansible.builtin.import_tasks: replication_primary.yml + when: mariadb_replication_role == "primary" - name: Include task replication_replica.yml ansible.builtin.import_tasks: replication_replica.yml diff --git a/tasks/replication_master.yml b/tasks/replication_primary.yml similarity index 86% rename from tasks/replication_master.yml rename to tasks/replication_primary.yml index 40b5bf4..7d9d462 100644 --- a/tasks/replication_master.yml +++ b/tasks/replication_primary.yml @@ -1,5 +1,5 @@ --- -- name: Ensure replication user exists on master +- name: Ensure replication user exists on primary node community.mysql.mysql_user: name: "{{ item.name }}" host: "{{ item.host | default('%') }}" diff --git a/tasks/replication_replica.yml b/tasks/replication_replica.yml index 9dd2804..0a69c7c 100644 --- a/tasks/replication_replica.yml +++ b/tasks/replication_replica.yml @@ -20,10 +20,10 @@ - name: Configure replication on the replica community.mysql.mysql_replication: mode: changeprimary - master_host: "{{ mariadb_replication_master_ip }}" - master_user: "{{ item.name }}" - master_password: "{{ item.password }}" - master_use_gtid: "{{ mariadb_replication_gtid | default('replica_pos') }}" + primary_host: "{{ mariadb_replication_primary_ip }}" + primary_user: "{{ item.name }}" + primary_password: "{{ item.password }}" + primary_use_gtid: "{{ mariadb_replication_gtid | default('replica_pos') }}" login_unix_socket: "{{ mariadb_unix_socket }}" loop: "{{ mariadb_replication_user }}" when: diff --git a/templates/mariadb.cnf.j2 b/templates/mariadb.cnf.j2 index 90dcfaf..fd4e001 100644 --- a/templates/mariadb.cnf.j2 +++ b/templates/mariadb.cnf.j2 @@ -25,13 +25,13 @@ server-id = {{ mariadb_server_id }} log-basename = mariadb -{% if mariadb_replication_role == 'master' %} +{% if mariadb_replication_role == 'primary' %} log_bin expire_logs_days = {{ mariadb_expire_logs_days }} max_binlog_size = {{ mariadb_max_binlog_size }} binlog_format = {{mariadb_binlog_format}} -# the following permits to simplify the process of moving a replica to a master -# role by ensuring that replication is not started on master +# the following permits to simplify the process of moving a replica to a +# primary node role by ensuring that replication is not started on primary node skip-slave-start {% for db in mariadb_databases %}