Remove slave statement when possible
See: https://jira.mariadb.org/browse/MDEV-18777
This commit is contained in:
		
							parent
							
								
									cd0ea2011e
								
							
						
					
					
						commit
						d1cdf270c6
					
				|  | @ -13,7 +13,7 @@ env: | ||||||
| 
 | 
 | ||||||
| before_install: | 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 |     then | ||||||
|       echo "Only doc files were updated, not running the CI." |       echo "Only doc files were updated, not running the CI." | ||||||
|       exit |       exit | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								README.md
								
								
								
								
							
							
						
						
									
										10
									
								
								README.md
								
								
								
								
							|  | @ -6,7 +6,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/slave cluster; | - deploy a master/replica cluster; | ||||||
| - setup backups and rotation of the dumps. | - setup backups and rotation of the dumps. | ||||||
| 
 | 
 | ||||||
| ## Requirements | ## Requirements | ||||||
|  | @ -175,9 +175,9 @@ 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 (`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: | `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> | ||||||
| 
 | 
 | ||||||
|  | @ -185,11 +185,11 @@ For the moment, we use an `SQL` command but in ansible 2.10, we should be able | ||||||
| to use the | to use the | ||||||
| [`mysql_replication`](https://docs.ansible.com/ansible/latest/modules/mysql_replication_module.html) | [`mysql_replication`](https://docs.ansible.com/ansible/latest/modules/mysql_replication_module.html) | ||||||
| module (see | module (see | ||||||
| [`tasks/replication_slave.yml`](./tasks/replication_slave.yml#L09-L33) and | [`tasks/replication_replica.yml`](./tasks/replication_replica.yml#L09-L33) and | ||||||
| <https://github.com/ansible/ansible/pull/62648>). | <https://github.com/ansible/ansible/pull/62648>). | ||||||
| 
 | 
 | ||||||
| ```yaml | ```yaml | ||||||
| mariadb_replication_role: "" # master|slave | mariadb_replication_role: "" # master|replica | ||||||
| mariadb_replication_master_ip: "" | mariadb_replication_master_ip: "" | ||||||
| mariadb_server_id: "1" | mariadb_server_id: "1" | ||||||
| mariadb_max_binlog_size: "100M" | mariadb_max_binlog_size: "100M" | ||||||
|  |  | ||||||
|  | @ -86,7 +86,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: "" # master|slave | mariadb_replication_role: "" # master|replica | ||||||
| mariadb_replication_master_ip: "" | mariadb_replication_master_ip: "" | ||||||
| mariadb_max_binlog_size: "100M" | mariadb_max_binlog_size: "100M" | ||||||
| mariadb_binlog_format: "MIXED" | mariadb_binlog_format: "MIXED" | ||||||
|  |  | ||||||
|  | @ -9,23 +9,23 @@ | ||||||
|   include_tasks: databases.yml |   include_tasks: databases.yml | ||||||
|   when: |   when: | ||||||
|     - mariadb_databases is defined |     - mariadb_databases is defined | ||||||
|     - mariadb_replication_role != "slave" |     - mariadb_replication_role != "replica" | ||||||
| 
 | 
 | ||||||
| - name: include task users.yml | - name: include task users.yml | ||||||
|   include_tasks: users.yml |   include_tasks: users.yml | ||||||
|   when: |   when: | ||||||
|     - mariadb_users is defined |     - mariadb_users is defined | ||||||
|     - mariadb_replication_role != "slave" |     - mariadb_replication_role != "replica" | ||||||
| 
 | 
 | ||||||
| - name: include task replication_master.yml | - name: include task replication_master.yml | ||||||
|   include_tasks: replication_master.yml |   include_tasks: replication_master.yml | ||||||
|   when: mariadb_replication_role == "master" |   when: mariadb_replication_role == "master" | ||||||
| 
 | 
 | ||||||
| - name: include task replication_slave.yml | - name: include task replication_replica.yml | ||||||
|   include_tasks: replication_slave.yml |   include_tasks: replication_replica.yml | ||||||
|   when: |   when: | ||||||
|     - not ansible_check_mode |     - not ansible_check_mode | ||||||
|     - mariadb_replication_role == "slave" |     - mariadb_replication_role == "replica" | ||||||
| 
 | 
 | ||||||
| - name: include task backup.yml | - name: include task backup.yml | ||||||
|   include_tasks: backup.yml |   include_tasks: backup.yml | ||||||
|  |  | ||||||
|  | @ -1,25 +1,25 @@ | ||||||
| --- | --- | ||||||
| - name: Check slave replication status | - name: Check replica replication status | ||||||
|   mysql_replication: |   mysql_replication: | ||||||
|     mode: getslave |     mode: getslave | ||||||
|     login_unix_socket: "{{ mariadb_unix_socket }}" |     login_unix_socket: "{{ mariadb_unix_socket }}" | ||||||
|   register: slave |   register: replica | ||||||
|   no_log: true |   no_log: true | ||||||
| 
 | 
 | ||||||
| # For the moment, we have to use a sql command. | # For the moment, we have to use a sql command. | ||||||
| # 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 slave | - name: Configure replication on the replica | ||||||
|   command: | |   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" | ||||||
|   with_items: "{{ mariadb_replication_user }}" |   with_items: "{{ mariadb_replication_user }}" | ||||||
|   when: |   when: | ||||||
|     - not slave.Is_Slave |     - not replica.Is_Slave | ||||||
|   no_log: true |   no_log: true | ||||||
| 
 | 
 | ||||||
| # # Following (not tested) should work on ansible 2.10 | # # Following (not tested) should work on ansible 2.10 | ||||||
| # - name: Configure replication on the slave | # - name: Configure replication on the replica | ||||||
| #   mysql_replication: | #   mysql_replication: | ||||||
| #     mode: changemaster | #     mode: changemaster | ||||||
| #     master_host: "{{ mariadb_replication_master_ip }}" | #     master_host: "{{ mariadb_replication_master_ip }}" | ||||||
|  | @ -29,26 +29,26 @@ | ||||||
| #     login_unix_socket: "{{ mariadb_unix_socket }}" | #     login_unix_socket: "{{ mariadb_unix_socket }}" | ||||||
| #   with_items: "{{ mariadb_replication_user }}" | #   with_items: "{{ mariadb_replication_user }}" | ||||||
| #   when: | #   when: | ||||||
| #     - not slave.Is_Slave | #     - not replica.Is_Slave | ||||||
| #   no_log: true | #   no_log: true | ||||||
| 
 | 
 | ||||||
| - name: Reset slave replication | - name: Reset replica replication | ||||||
|   mysql_replication: |   mysql_replication: | ||||||
|     mode: resetslave |     mode: resetslave | ||||||
|     login_unix_socket: "{{ mariadb_unix_socket }}" |     login_unix_socket: "{{ mariadb_unix_socket }}" | ||||||
|   when: |   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: |   mysql_replication: | ||||||
|     mode: getslave |     mode: getslave | ||||||
|     login_unix_socket: "{{ mariadb_unix_socket }}" |     login_unix_socket: "{{ mariadb_unix_socket }}" | ||||||
|   register: slave2 |   register: replica2 | ||||||
|   no_log: true |   no_log: true | ||||||
| 
 | 
 | ||||||
| - name: Start slave replication | - name: Start replica replication | ||||||
|   mysql_replication: |   mysql_replication: | ||||||
|     mode: startslave |     mode: startslave | ||||||
|     login_unix_socket: "{{ mariadb_unix_socket }}" |     login_unix_socket: "{{ mariadb_unix_socket }}" | ||||||
|   when: |   when: | ||||||
|     - slave2.Slave_IO_Running == "No" |     - replica2.Slave_IO_Running == "No" | ||||||
|  | @ -25,7 +25,7 @@ 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 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 | # role by ensuring that replication is not started on master | ||||||
| skip-slave-start | skip-slave-start | ||||||
| 
 | 
 | ||||||
|  | @ -38,7 +38,7 @@ binlog_ignore_db = {{ db.name }} | ||||||
| {% endfor %} | {% endfor %} | ||||||
| {% endif %} | {% endif %} | ||||||
| 
 | 
 | ||||||
| {% if mariadb_replication_role == 'slave' %} | {% if mariadb_replication_role == 'replica' %} | ||||||
| read_only | read_only | ||||||
| relay-log = relay-bin | relay-log = relay-bin | ||||||
| relay-log-index = relay-bin.index | relay-log-index = relay-bin.index | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue