Skip to content

Commit

Permalink
Merge branch 'mrlesmithjr:master' into upstreaming
Browse files Browse the repository at this point in the history
  • Loading branch information
andanotheruser committed Nov 14, 2024
2 parents b15cde4 + a83a130 commit 05c2cdd
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 57 deletions.
63 changes: 29 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions tasks/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,4 @@
become: true
when: mariadb_config_overrides is defined

- name: debian | installing mariadb-galera packages
ansible.builtin.apt:
name: "{{ (galera_sst_method == 'mariabackup') | ternary( mariadb_packages | union( mariabackup_packages ), mariadb_packages ) }}"
state: "present"
become: true
- ansible.builtin.import_tasks: mariadb_packages_install.yml
7 changes: 7 additions & 0 deletions tasks/mariadb_packages_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: mariadb_packages_install | installing mariadb-galera packages
ansible.builtin.package:
name: "{{ (galera_sst_method == 'mariabackup') | ternary( mariadb_packages | union( mariabackup_packages ), mariadb_packages ) }}"
state: "{{ mariadb_upgrade | ternary( 'latest', 'present' ) }}"
update_cache: true
become: true
7 changes: 1 addition & 6 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@
become: true
when: mariadb_config_overrides is defined

- name: redhat | installing mariadb mysql
ansible.builtin.yum:
name: "{{ (galera_sst_method == 'mariabackup') | ternary( mariadb_packages | union( mariabackup_packages ), mariadb_packages ) }}"
state: "present"
update_cache: true
become: true
- ansible.builtin.import_tasks: mariadb_packages_install.yml

- name: redhat | remove migrated-from-my.cnf-settings.conf that is causing MariaDB to not start
ansible.builtin.file:
Expand Down
21 changes: 11 additions & 10 deletions tasks/setup_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
become: true
no_log: true
notify: restart cluster
register: _mariadb_galera_cluster_newcerts
when:
- mariadb_tls_files is defined
- mariadb_tls_files | length == 3
Expand All @@ -50,7 +51,7 @@
galera_extra_wsrep_provider_options: >
{{
galera_extra_wsrep_provider_options | combine({
'ist.recv_addr': galera_ist_recv_addr + ":" + galera_ist_recv_addr_port,
'ist.recv_addr': galera_ist_recv_addr + ":" + galera_ist_recv_addr_port|string,
'ist.recv_bind': galera_ist_recv_bind
})
}}
Expand All @@ -70,8 +71,7 @@
- galera_wsrep_tls_enabled
- name: Add galera_use_gmcast_segment if present
set_fact:
galera_extra_wsrep_provider_options: "{{ galera_extra_wsrep_provider_options | combine({ 'gmcast.segment': hostvars[inventory_hostname]['galera_gmcast_segment']|int
}) }}"
galera_extra_wsrep_provider_options: "{{ galera_extra_wsrep_provider_options | combine({ 'gmcast.segment': hostvars[inventory_hostname]['galera_gmcast_segment']|int }) }}"
when:
- galera_use_gmcast_segment
- ('galera_gmcast_segment' in hostvars[inventory_hostname])
Expand All @@ -88,27 +88,28 @@
follow: true
become: true
register: "_mariadb_galera_cluster_reconfigured"
notify: restart cluster
loop: "{{ mariadb_confs }}"
loop_control:
loop_var: file

- name: setup_cluster | cluster rolling restart - apply config changes (first node)
ansible.builtin.include_tasks: restart_cluster.yml
ansible.builtin.include_tasks: manage_node_state.yml
vars:
mariadb_systemd_service_state: "restarted"
with_items: "{{ galera_mysql_first_node }}"
when: >
galera_cluster_configured.stat.exists and
_mariadb_galera_cluster_reconfigured.changed or
(_mariadb_galera_cluster_reconfigured.changed or
_mariadb_galera_cluster_newcerts.changed)
- name: setup_cluster | cluster rolling restart - apply config changes (other nodes)
ansible.builtin.include_tasks: restart_cluster.yml
ansible.builtin.include_tasks: manage_node_state.yml
vars:
mariadb_systemd_service_state: "restarted"
with_items: "{{ ansible_play_hosts | difference(galera_mysql_first_node) }}"
when: >
galera_cluster_configured.stat.exists and
_mariadb_galera_cluster_reconfigured.changed or
(_mariadb_galera_cluster_reconfigured.changed or
_mariadb_galera_cluster_newcerts.changed)
# Offline (re)configuration of glaera cluster settings - cluster bootstrap
Expand Down Expand Up @@ -161,7 +162,7 @@
not galera_cluster_configured.stat.exists
- name: setup_cluster | cluster bootstrap - joining galera cluster
ansible.builtin.include_tasks: manage_node_state.yml
include_tasks: manage_node_state.yml
vars:
mariadb_systemd_service_state: "started"
with_items: "{{ ansible_play_hosts | difference(galera_mysql_first_node) }}"
Expand All @@ -182,7 +183,7 @@
inventory_hostname == galera_mysql_first_node
- name: setup_cluster | cluster bootstrap - restarting first node with final galera config
ansible.builtin.include_tasks: manage_node_state.yml
include_tasks: manage_node_state.yml
vars:
mariadb_systemd_service_state: "restarted"
with_items: "{{ galera_mysql_first_node }}"
Expand Down
2 changes: 2 additions & 0 deletions tests/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
inventory = ./inventory
58 changes: 58 additions & 0 deletions tests/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---

- name: Creating Galera Test Scenario
hosts: localhost
vars:
openstack_cloud: testing
openstack_ssh_key: testing
openstack_flavor_name: gp1a.4
openstack_image_name_deb12: debian-12-generic-amd64
openstack_image_name_deb11: debian-11-generic-amd64
openstack_network_name: network-k0stesting_generic
tasks:
- name: Include variables
ansible.builtin.include_vars: "vars/main.yml"

- name: Fetch Image (Deb12)

Check failure on line 16 in tests/create.yml

View workflow job for this annotation

GitHub Actions / pre-commit Lint

syntax-check[specific]

couldn't resolve module/action 'openstack.cloud.image_info'. This often indicates a misspelling, missing collection, or incorrect module path.
openstack.cloud.image_info:
cloud: "{{ openstack_cloud }}"
image: "{{ openstack_image_name_deb12 }}"
register: _openstack_image_deb12

- name: Fetch Flavor
openstack.cloud.compute_flavor_info:
cloud: "{{ openstack_cloud }}"
name: "{{ openstack_flavor_name }}"
register: _openstack_flavor

- name: Fetch Network
openstack.cloud.networks_info:
cloud: "{{ openstack_cloud }}"
name: "{{ openstack_network_name }}"
register: _openstack_network

- name: Ensure SSH Key exists
openstack.cloud.keypair:
name: "{{ openstack_ssh_key }}"
cloud: "{{ openstack_cloud }}"
public_key_file: "{{ ansible_env.HOME }}/.ssh/testing.pub"

- name: Create Galera Instances
openstack.cloud.server:
name: "{{ item }}"
state: present
image: "{{ _openstack_image_deb12.images[0].id }}"
key_name: "{{ openstack_ssh_key }}"
flavor: "{{ _openstack_flavor.flavors[0].id }}"
network: "{{ _openstack_network.networks[0].id }}"
terminate_volume: true
security_groups:
- 1aa4fd40-1650-4151-84a7-3f5ecc4c4b23
cloud: "{{ openstack_cloud }}"
metadata:
group: "{{ the_role_name }}"
auto_ip: false
loop:
- galera-1
- galera-2
- galera-3
17 changes: 17 additions & 0 deletions tests/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

- name: Destroying Test Scenario
hosts: localhost
vars:
openstack_cloud: testing
tasks:

- name: Destroy Instances

Check failure on line 9 in tests/destroy.yml

View workflow job for this annotation

GitHub Actions / pre-commit Lint

syntax-check[specific]

couldn't resolve module/action 'openstack.cloud.server'. This often indicates a misspelling, missing collection, or incorrect module path.
openstack.cloud.server:
state: absent
name: "{{ item }}"
cloud: "{{ openstack_cloud }}"
loop:
- galera-1
- galera-2
- galera-3
12 changes: 12 additions & 0 deletions tests/inventory/openstack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
plugin: openstack.cloud.openstack
expand_hostvars: true
private: true
legacy_groups: false
keyed_groups:
- key: openstack.metadata.group
default_value: galera
parent_group: all
leading_separator: false
only_clouds:
- testing
63 changes: 63 additions & 0 deletions tests/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---

- name: Creating Test Environment for Galera
hosts: mariadb_galera_cluster
order: sorted
pre_tasks:
- name: Set hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
become: true
- name: Reload facts
ansible.builtin.setup:
- name: Refresh Inventory
ansible.builtin.meta: refresh_inventory
- name: Set Hostnames
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ hostvars[item].ansible_facts.default_ipv4.address }} {{ hostvars[item].ansible_facts.fqdn }}"
become: true
loop: "{{ ansible_play_hosts }}"
- name: Set Hostnames IPv6
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ hostvars[item].ansible_facts.default_ipv6.address }} {{ hostvars[item].ansible_facts.fqdn }}"
become: true
loop: "{{ ansible_play_hosts }}"
- name: Include variables
ansible.builtin.include_vars: "vars/main.yml"
- name: Load mysqld_exporter vars
ansible.builtin.include_vars:
file: mysqld_exporter.yml
roles:
- role: adit.mariadb_galera_cluster

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / pre-commit Lint

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (debian10, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (debian11, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (debian12, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (rocky8, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (rocky9, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (ubuntu1804, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (ubuntu2004, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests

Check failure on line 33 in tests/playbook.yml

View workflow job for this annotation

GitHub Actions / Molecule Test (ubuntu2204, 3.10)

syntax-check[specific]

the role 'adit.mariadb_galera_cluster' was not found in /home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests/roles:/home/runner/.cache/ansible-compat/c01d4a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-mariadb-galera-cluster/ansible-mariadb-galera-cluster/tests
tags:
- mariadb_galera_cluster

- name: MySQL Clustercheck
hosts: mariadb_galera_cluster
order: sorted
pre_tasks:
- name: Include variables
ansible.builtin.include_vars: "vars/main.yml"
- name: Load mysqld_exporter vars
ansible.builtin.include_vars:
file: mysqld_exporter.yml
roles:
- role: adit.mysql_clustercheck
tags:
- mysql_clustercheck

- name: MySQL Clustercheck
hosts: mariadb_galera_cluster
order: sorted
pre_tasks:
- name: Include variables
ansible.builtin.include_vars: "vars/main.yml"
- name: Load mysqld_exporter vars
ansible.builtin.include_vars:
file: mysqld_exporter.yml
roles:
- role: prometheus.prometheus.mysqld_exporter
tags:
- prometheus_mysqld_exporter
Loading

0 comments on commit 05c2cdd

Please sign in to comment.