diff --git a/.travis.yml b/.travis.yml index a6eb386..81413c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: before_install: - | - if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.md)|(.pdf)' + if ! git diff --name-only HEAD^ | grep -vE '(.md)|(.pdf)' then echo "Only doc files were updated, not running the CI." exit diff --git a/README.md b/README.md index 598f08c..0be2b85 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Install and configure MariaDB Server on Debian/Ubuntu. Optionally, this role also permits one to: -- deploy a master/slave cluster; +- deploy a master/replica cluster; - setup backups and rotation of the dumps. ## Requirements @@ -175,9 +175,9 @@ See: ### Replication (optional) Replication is only enabled if `mariadb_replication_role` has a value (`master` or -`slave`). +`replica`). -The replication setup on the slave use the GTID autopositioning +The replication setup on the replica use the GTID autopositioning `master_use_gtid=slave_pos`. See: @@ -185,11 +185,11 @@ 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_slave.yml`](./tasks/replication_slave.yml#L09-L33) and +[`tasks/replication_replica.yml`](./tasks/replication_replica.yml#L09-L33) and ). ```yaml -mariadb_replication_role: "" # master|slave +mariadb_replication_role: "" # master|replica mariadb_replication_master_ip: "" mariadb_server_id: "1" mariadb_max_binlog_size: "100M" diff --git a/defaults/main.yml b/defaults/main.yml index bcac895..d4ba4ae 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -86,7 +86,7 @@ mariadb_users: [] # Replication # replication is only enabled if mariadb_replication_role has values -mariadb_replication_role: "" # master|slave +mariadb_replication_role: "" # master|replica mariadb_replication_master_ip: "" mariadb_max_binlog_size: "100M" mariadb_binlog_format: "MIXED" diff --git a/tasks/main.yml b/tasks/main.yml index 9ca9cf3..3c85571 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,23 +9,23 @@ include_tasks: databases.yml when: - mariadb_databases is defined - - mariadb_replication_role != "slave" + - mariadb_replication_role != "replica" - name: include task users.yml include_tasks: users.yml when: - mariadb_users is defined - - mariadb_replication_role != "slave" + - mariadb_replication_role != "replica" - name: include task replication_master.yml include_tasks: replication_master.yml when: mariadb_replication_role == "master" -- name: include task replication_slave.yml - include_tasks: replication_slave.yml +- name: include task replication_replica.yml + include_tasks: replication_replica.yml when: - not ansible_check_mode - - mariadb_replication_role == "slave" + - mariadb_replication_role == "replica" - name: include task backup.yml include_tasks: backup.yml diff --git a/tasks/replication_slave.yml b/tasks/replication_replica.yml similarity index 76% rename from tasks/replication_slave.yml rename to tasks/replication_replica.yml index 6c9ad0d..5a6861c 100644 --- a/tasks/replication_slave.yml +++ b/tasks/replication_replica.yml @@ -1,25 +1,25 @@ --- -- name: Check slave replication status +- name: Check replica replication status mysql_replication: mode: getslave login_unix_socket: "{{ mariadb_unix_socket }}" - register: slave + register: replica no_log: true # For the moment, we have to use a sql command. # In ansible 2.10, we should be able to use mysql_replication module. # See https://github.com/ansible/ansible/pull/62648 (and below) -- name: Configure replication on the slave +- name: Configure replication on the replica command: | /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" with_items: "{{ mariadb_replication_user }}" when: - - not slave.Is_Slave + - not replica.Is_Slave no_log: true # # Following (not tested) should work on ansible 2.10 -# - name: Configure replication on the slave +# - name: Configure replication on the replica # mysql_replication: # mode: changemaster # master_host: "{{ mariadb_replication_master_ip }}" @@ -29,26 +29,26 @@ # login_unix_socket: "{{ mariadb_unix_socket }}" # with_items: "{{ mariadb_replication_user }}" # when: -# - not slave.Is_Slave +# - not replica.Is_Slave # no_log: true -- name: Reset slave replication +- name: Reset replica replication mysql_replication: mode: resetslave login_unix_socket: "{{ mariadb_unix_socket }}" when: - - not slave.Is_Slave + - not replica.Is_Slave -- name: Check slave replication status (second time) +- name: Check replica replication status (second time) mysql_replication: mode: getslave login_unix_socket: "{{ mariadb_unix_socket }}" - register: slave2 + register: replica2 no_log: true -- name: Start slave replication +- name: Start replica replication mysql_replication: mode: startslave login_unix_socket: "{{ mariadb_unix_socket }}" when: - - slave2.Slave_IO_Running == "No" + - replica2.Slave_IO_Running == "No" diff --git a/templates/my.cnf.j2 b/templates/my.cnf.j2 index 94cd4c4..5a84114 100644 --- a/templates/my.cnf.j2 +++ b/templates/my.cnf.j2 @@ -25,7 +25,7 @@ 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 slave to a master +# the following permits to simplify the process of moving a replica to a master # role by ensuring that replication is not started on master skip-slave-start @@ -38,7 +38,7 @@ binlog_ignore_db = {{ db.name }} {% endfor %} {% endif %} -{% if mariadb_replication_role == 'slave' %} +{% if mariadb_replication_role == 'replica' %} read_only relay-log = relay-bin relay-log-index = relay-bin.index