diff --git a/defaults/main.yml b/defaults/main.yml index e96d5448..b7f0779a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,7 +16,8 @@ ## APT Cache Options cache_timeout: 600 -galera_server_bootstrap_node: "{{ groups['galera_all'][0] }}" +galera_cluster_members: "{{ groups['galera_all'] }}" +galera_server_bootstrap_node: "{{ galera_cluster_members[0] }}" galera_ignore_cluster_state: false galera_upgrade: false @@ -53,7 +54,7 @@ galera_innodb_log_buffer_size: 128M ## wsrep configuration galera_wsrep_address: "{{ ansible_ssh_host }}" -galera_wsrep_cluster_address: "{% for host in groups['galera_all'] %}{{ hostvars[host]['ansible_ssh_host'] }}{% if not loop.last %},{% endif %}{% endfor %}" +galera_wsrep_cluster_address: "{% for host in galera_cluster_members %}{{ hostvars[host]['ansible_ssh_host'] }}{% if not loop.last %},{% endif %}{% endfor %}" galera_wsrep_node_incoming_address: "{{ galera_wsrep_address }}" galera_wsrep_slave_threads: "{{ ansible_processor_vcpus | default(2) }}" galera_wsrep_retry_autocommit: 3 diff --git a/handlers/main.yml b/handlers/main.yml index 50b97869..0f305cb8 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -19,7 +19,7 @@ state: restarted sleep: 2 pattern: mysql - args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) or (groups['galera_all'] | length == 1) | ternary('--wsrep-new-cluster', '') }}" + args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) or (galera_cluster_members | length == 1) | ternary('--wsrep-new-cluster', '') }}" environment: MYSQLD_STARTUP_TIMEOUT: 180 when: not galera_running_and_bootstrapped | bool @@ -46,7 +46,7 @@ state: restarted sleep: 2 pattern: mysql - args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) or (groups['galera_all'] | length == 1) | ternary('--wsrep-new-cluster', '') }}" + args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) or (galera_cluster_members | length == 1) | ternary('--wsrep-new-cluster', '') }}" environment: MYSQLD_STARTUP_TIMEOUT: 180 when: galera_restart | failed diff --git a/meta/main.yml b/meta/main.yml index 8c492749..7255fd60 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -31,4 +31,5 @@ galaxy_info: - openstack dependencies: - apt_package_pinning - - galera_client + - role: galera_client + galera_client_drop_config_file: true diff --git a/tasks/main.yml b/tasks/main.yml index 8c4da000..36e58cb6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +- fail: + msg: "The host {{ inventory_hostname }} must be in galera_cluster_members." + when: inventory_hostname not in galera_cluster_members + - name: Fail if the galera root password is not provided fail: msg: | diff --git a/templates/my.cnf.j2 b/templates/my.cnf.j2 index dfa8b90f..3562d41b 100644 --- a/templates/my.cnf.j2 +++ b/templates/my.cnf.j2 @@ -1,5 +1,5 @@ {%- set all_calculated_max_connections = [] %} -{%- for galera_node in groups['galera_all'] %} +{%- for galera_node in galera_cluster_members %} {%- if all_calculated_max_connections.append(hostvars[galera_node]['ansible_processor_vcpus'] | default(2) * 100) %} {%- endif %} {%- endfor %} diff --git a/templates/mysql_defaults.j2 b/templates/mysql_defaults.j2 index ea52a47e..c2e13b83 100644 --- a/templates/mysql_defaults.j2 +++ b/templates/mysql_defaults.j2 @@ -1,7 +1,7 @@ # {{ ansible_managed }} {%- set all_calculated_max_connections = [] %} -{%- for galera_node in groups['galera_all'] %} +{%- for galera_node in galera_cluster_members %} {%- set _ = all_calculated_max_connections.append(hostvars[galera_node]['ansible_processor_vcpus'] | default(2) * 100) %} {%- endfor %} {%- set calculated_min_connections = all_calculated_max_connections | min %} diff --git a/tests/test-functional.yml b/tests/test-functional.yml index c0b9214e..890287af 100644 --- a/tests/test-functional.yml +++ b/tests/test-functional.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Playbook for testing - hosts: galera_all + hosts: galera_test_hosts user: root gather_facts: true vars: diff --git a/tests/test-prep.yml b/tests/test-prep.yml index 71490dc6..805ba1bf 100644 --- a/tests/test-prep.yml +++ b/tests/test-prep.yml @@ -70,7 +70,7 @@ # done for functional testing. - name: Create container hosts add_host: - groups: "all,all_containers,galera_all" + groups: "all,all_containers,galera_test_hosts" hostname: "{{ item.name }}" inventory_hostname: "{{ item.name }}" ansible_ssh_host: "{{ item.address }}" diff --git a/tests/test.yml b/tests/test.yml index 8927d06f..6a6b68b4 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -21,11 +21,12 @@ # Deploy the environment - name: Playbook for role testing - hosts: galera_all + hosts: galera_test_hosts serial: 1 user: root gather_facts: true vars: + galera_cluster_members: "{{ groups['galera_test_hosts'] }}" galera_root_password: secrete galera_root_user: root galera_innodb_buffer_pool_size: 512M @@ -48,11 +49,12 @@ # Deploy the environment running a 5.5 to 10.0 upgrade - name: Playbook for role upgrade testing - hosts: galera_all + hosts: galera_test_hosts serial: 1 user: root gather_facts: true vars: + galera_cluster_members: "{{ groups['galera_test_hosts'] }}" galera_root_password: secrete galera_root_user: root galera_innodb_buffer_pool_size: 512M @@ -75,11 +77,12 @@ # Deploy the environment running a 5.5 to 10.0 upgrade - name: Playbook for role upgrade testing - hosts: galera_all + hosts: galera_test_hosts serial: 1 user: root gather_facts: true vars: + galera_cluster_members: "{{ groups['galera_test_hosts'] }}" galera_root_password: secrete galera_root_user: root galera_innodb_buffer_pool_size: 512M