diff --git a/.fixtures.yml b/.fixtures.yml
index 10d8551..78edc20 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -8,5 +8,6 @@ fixtures:
"provision": "https://github.com/puppetlabs/provision.git"
"puppet_agent": "https://github.com/puppetlabs/puppetlabs-puppet_agent.git"
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git"
+ "systemd": "https://github.com/voxpupuli/puppet-systemd.git"
"xinetd": "https://github.com/puppetlabs/puppetlabs-xinetd.git"
"yumrepo_core": "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a172835..e2e2366 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Added
+* Add new parameter `$status_check_type`
+* Add new parameter `$status_systemd_service_name`
+* Add systemd-based status check ([#191])
+* Add support for new operating systems
+
+### Changed
+* Enable systemd-based status check on RHEL 9, Debian 12 and Ubuntu 24.04 ([#191])
+* Add new dependency for systemd-based status check ([#191])
+* Extend unit tests ([#191])
+
## [3.2.1] - 2024-03-13
### Changed
@@ -313,6 +326,7 @@ This is the first release after extensive code refactoring and introduces multip
[0.7.2]: https://github.com/markt-de/puppet-galera/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/markt-de/puppet-galera/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/markt-de/puppet-galera/compare/0.0.6...0.7.0
+[#191]: https://github.com/markt-de/puppet-galera/pull/191
[#186]: https://github.com/markt-de/puppet-galera/pull/186
[#185]: https://github.com/markt-de/puppet-galera/pull/185
[#179]: https://github.com/markt-de/puppet-galera/pull/179
diff --git a/README.md b/README.md
index 2c44eed..5126505 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,9 @@ It will try to recover from failures by bootstrapping on a node designated as th
* [puppetlabs/mysql](https://github.com/puppetlabs/puppetlabs-mysql) and other soft dependencies
* A [supported version](#os-and-cluster-compatibility) of Codership Galera (MySQL), MariaDB or Percona XtraDB Cluster
* `nmap` is required for the cluster bootstrap functionality
+* [puppetlabs/xinetd](https://github.com/puppetlabs/puppetlabs-xinetd) if `galera::status_type` is set to `xinetd` (default for FreeBSD)
+* [puppet/systemd](https://github.com/voxpupuli/puppet-systemd) if `galera::status_type` is set to `systemd` (default for newer Linux distributions)
+* [puppetlabs/firewall](https://github.com/puppetlabs/puppetlabs-firewall) unless `galera::configure_firewall` is disabled
## Usage
diff --git a/REFERENCE.md b/REFERENCE.md
index b34792f..fe572e2 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -18,9 +18,7 @@
* `galera::redhat`: Adds workarounds to solve issues specific to RedHat-based systems.
* `galera::repo`: Evaluates which repositories should be enabled depending on $vendor_type and $vendor_version.
* `galera::status`: Configures a user and script that will check the status of the galera cluster.
-* `galera::validate`: Validate that the cluster can accept connections at the point where
-the `mysql::server` resource is marked as complete.
-This is used because after returning success, the service is still not quite ready.
+* `galera::validate`: Validate that the cluster can accept connections.
### Defined types
@@ -82,6 +80,7 @@ The following parameters are available in the `galera` class:
* [`status_available_when_donor`](#-galera--status_available_when_donor)
* [`status_available_when_readonly`](#-galera--status_available_when_readonly)
* [`status_check`](#-galera--status_check)
+* [`status_check_type`](#-galera--status_check_type)
* [`status_cps`](#-galera--status_cps)
* [`status_flags`](#-galera--status_flags)
* [`status_host`](#-galera--status_host)
@@ -98,6 +97,7 @@ The following parameters are available in the `galera` class:
* [`status_system_group`](#-galera--status_system_group)
* [`status_system_user`](#-galera--status_system_user)
* [`status_system_user_config`](#-galera--status_system_user_config)
+* [`status_systemd_service_name`](#-galera--status_systemd_service_name)
* [`status_user`](#-galera--status_user)
* [`status_xinetd_service_name`](#-galera--status_xinetd_service_name)
* [`validate_connection`](#-galera--validate_connection)
@@ -454,6 +454,13 @@ Data type: `Boolean`
Specifies whether to configure a user and script that will check the status
of the galera cluster. Default: `true`
+##### `status_check_type`
+
+Data type: `Enum['systemd', 'xinetd']`
+
+Specifies the type of service to use for status checks. Supported values
+are either `systemd` or `xinetd`, depending on the operating system.
+
##### `status_cps`
Data type: `Optional[String]`
@@ -567,6 +574,12 @@ Data type: `Hash`
The config for the operating system user.
+##### `status_systemd_service_name`
+
+Data type: `String`
+
+The name of the systemd status service.
+
##### `status_user`
Data type: `String`
@@ -578,7 +591,7 @@ Default: `clustercheck`
Data type: `String`
-The name of the xinetd service.
+The name of the xinetd status service.
##### `validate_connection`
diff --git a/data/Debian-10.yaml b/data/Debian-10.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Debian-10.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/Debian-11.yaml b/data/Debian-11.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Debian-11.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/Debian-8.yaml b/data/Debian-8.yaml
index 1582683..0a4fbca 100644
--- a/data/Debian-8.yaml
+++ b/data/Debian-8.yaml
@@ -3,3 +3,5 @@ galera::repo::mariadb::apt:
key:
id: '199369E5404BD5FC7D2FE43BCBCB082A1BB943DB'
server: 'keyserver.ubuntu.com'
+
+galera::status_check_type: 'xinetd'
diff --git a/data/Debian-9.yaml b/data/Debian-9.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Debian-9.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/FreeBSD-family.yaml b/data/FreeBSD-family.yaml
index 4d2443f..33b3965 100644
--- a/data/FreeBSD-family.yaml
+++ b/data/FreeBSD-family.yaml
@@ -3,6 +3,8 @@
galera::configure_firewall: false
galera::configure_repo: false
+galera::status_check_type: 'xinetd'
+
#
# Codership - version-specific settings
#
diff --git a/data/RedHat-6-family.yaml b/data/RedHat-6-family.yaml
index 470808b..e839039 100644
--- a/data/RedHat-6-family.yaml
+++ b/data/RedHat-6-family.yaml
@@ -10,3 +10,5 @@ galera::percona::55::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::56::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::57::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
galera::percona::bootstrap_command: '/etc/init.d/mysql bootstrap-pxc'
+
+galera::status_check_type: 'xinetd'
diff --git a/data/RedHat-7-family.yaml b/data/RedHat-7-family.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/RedHat-7-family.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/RedHat-8-family.yaml b/data/RedHat-8-family.yaml
index b083fd5..c27e616 100644
--- a/data/RedHat-8-family.yaml
+++ b/data/RedHat-8-family.yaml
@@ -20,3 +20,5 @@ galera::repo::percona::yum:
galera::repo::percona_tools::yum:
priority: 1
module_hotfixes: 1
+
+galera::status_check_type: 'xinetd'
diff --git a/data/Ubuntu-18.04.yaml b/data/Ubuntu-18.04.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Ubuntu-18.04.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/Ubuntu-20.04.yaml b/data/Ubuntu-20.04.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Ubuntu-20.04.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/Ubuntu-22.04.yaml b/data/Ubuntu-22.04.yaml
new file mode 100644
index 0000000..9709d11
--- /dev/null
+++ b/data/Ubuntu-22.04.yaml
@@ -0,0 +1,2 @@
+---
+galera::status_check_type: 'xinetd'
diff --git a/data/common.yaml b/data/common.yaml
index f59022a..15100c9 100644
--- a/data/common.yaml
+++ b/data/common.yaml
@@ -56,6 +56,7 @@ galera::status_allow: '%'
galera::status_available_when_donor: 0
galera::status_available_when_readonly: -1
galera::status_check: true
+galera::status_check_type: 'systemd'
galera::status_flags: 'REUSE'
galera::status_host: 'localhost'
galera::status_log_on_success: ''
@@ -69,6 +70,7 @@ galera::status_system_user_config:
home: '/var/empty'
shell: '/bin/false'
galera::status_user: 'clustercheck'
+galera::status_systemd_service_name: 'mysqlchk'
galera::status_xinetd_service_name: 'mysqlchk'
galera::validate::action: 'select count(1);'
galera::validate::catch: 'ERROR'
diff --git a/manifests/init.pp b/manifests/init.pp
index 5bf94f6..3de04de 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -183,6 +183,10 @@
# Specifies whether to configure a user and script that will check the status
# of the galera cluster. Default: `true`
#
+# @param status_check_type
+# Specifies the type of service to use for status checks. Supported values
+# are either `systemd` or `xinetd`, depending on the operating system.
+#
# @param status_cps
# Rate limit config for the xinetd status service.
#
@@ -232,12 +236,15 @@
# @param status_system_user_config
# The config for the operating system user.
#
+# @param status_systemd_service_name
+# The name of the systemd status service.
+#
# @param status_user
# Specifies the name of the user to use for status checks.
# Default: `clustercheck`
#
# @param status_xinetd_service_name
-# The name of the xinetd service.
+# The name of the xinetd status service.
#
# @param validate_connection
# Specifies whether the module should ensure that the cluster can accept
@@ -307,6 +314,7 @@
Integer $status_available_when_donor,
Integer $status_available_when_readonly,
Boolean $status_check,
+ Enum['systemd', 'xinetd'] $status_check_type,
Stdlib::Absolutepath $status_script,
String $status_host,
String $status_log_on_success_operator,
@@ -315,6 +323,7 @@
String $status_system_group,
String $status_system_user,
Hash $status_system_user_config,
+ String $status_systemd_service_name,
String $status_user,
String $status_xinetd_service_name,
Boolean $validate_connection,
diff --git a/manifests/status.pp b/manifests/status.pp
index 3769b99..b07375d 100644
--- a/manifests/status.pp
+++ b/manifests/status.pp
@@ -51,33 +51,75 @@
mode => '0500',
}
- xinetd::service { $galera::status_xinetd_service_name:
- cps => $galera::status_cps,
- flags => $galera::status_flags,
- instances => $galera::status_instances,
- log_on_failure => $galera::status_log_on_failure,
- log_on_failure_operator => $galera::status_log_on_failure_operator,
- log_on_success => $galera::status_log_on_success,
- log_on_success_operator => $galera::status_log_on_success_operator,
- log_type => $galera::status_log_type,
- port => $galera::status_port,
- server => $galera::status_script,
- service_type => $galera::status_service_type,
- user => $galera::status_system_user,
- require => [
- File[$galera::status_script],
- User[$galera::status_system_user]
- ],
- }
+ case $galera::status_check_type {
+ 'xinetd': {
+ xinetd::service { $galera::status_xinetd_service_name:
+ cps => $galera::status_cps,
+ flags => $galera::status_flags,
+ instances => $galera::status_instances,
+ log_on_failure => $galera::status_log_on_failure,
+ log_on_failure_operator => $galera::status_log_on_failure_operator,
+ log_on_success => $galera::status_log_on_success,
+ log_on_success_operator => $galera::status_log_on_success_operator,
+ log_type => $galera::status_log_type,
+ port => $galera::status_port,
+ server => $galera::status_script,
+ service_type => $galera::status_service_type,
+ user => $galera::status_system_user,
+ require => [
+ File[$galera::status_script],
+ User[$galera::status_system_user]
+ ],
+ }
- # Postpone the xinetd stuff. This is necessary in order to avoid package
- # conflicts. On some platforms xinetd depends on MySQL libs. If installed
- # too early it will install the wrong MySQL libs. This may cause the
- # installation of the Galera packages to fail.
- # This has been first observed on Debian 9 with Codership Galera 5.7 where
- # the package installation just ended with a conflict instead of replacing
- # the wrong MySQL libs. The root cause is likely a packaging bug in the
- # Codership distribution, since this issue could not be reproduced for
- # Percona.
- Exec<| title == 'bootstrap_galera_cluster' |> -> Class['xinetd']
+ # Postpone the xinetd stuff. This is necessary in order to avoid package
+ # conflicts. On some platforms xinetd depends on MySQL libs. If installed
+ # too early it will install the wrong MySQL libs. This may cause the
+ # installation of the Galera packages to fail.
+ # This has been first observed on Debian 9 with Codership Galera 5.7 where
+ # the package installation just ended with a conflict instead of replacing
+ # the wrong MySQL libs. The root cause is likely a packaging bug in the
+ # Codership distribution, since this issue could not be reproduced for
+ # Percona.
+ Exec<| title == 'bootstrap_galera_cluster' |> -> Class['xinetd']
+ }
+ 'systemd': {
+ # Generate a socket and service (xinetd style).
+ systemd::manage_unit { "${galera::status_systemd_service_name}@.service":
+ unit_entry => {
+ 'Description' => "${galera::status_systemd_service_name} service",
+ 'After' => ['network.target', 'network-online.target'],
+ 'Wants' => ['network-online.target'],
+ },
+ service_entry => {
+ 'User' => $galera::status_system_user,
+ 'Group' => $galera::status_system_group,
+ 'StandardInput' => 'socket',
+ 'ExecStart' => $galera::status_script,
+ },
+ require => File[$galera::status_script],
+ }
+ -> systemd::manage_unit { "${galera::status_systemd_service_name}.socket":
+ enable => true,
+ active => true,
+ unit_entry => {
+ 'Description' => "${galera::status_systemd_service_name} socket",
+ },
+ socket_entry => {
+ 'ListenStream' => $galera::status_port,
+ 'Accept' => true,
+ },
+ install_entry => {
+ 'WantedBy' => 'sockets.target',
+ },
+ }
+ # Migration path - remove xinetd service
+ file { "/etc/xinetd.d/${galera::status_xinetd_service_name}":
+ ensure => 'absent',
+ }
+ }
+ default: {
+ fail('unkown type of `galera::status_check_type` defined')
+ }
+ }
}
diff --git a/manifests/validate.pp b/manifests/validate.pp
index 4702a22..da23ba6 100644
--- a/manifests/validate.pp
+++ b/manifests/validate.pp
@@ -1,6 +1,8 @@
-# @summary Validate that the cluster can accept connections at the point where
-# the `mysql::server` resource is marked as complete.
-# This is used because after returning success, the service is still not quite ready.
+# @summary Validate that the cluster can accept connections.
+#
+# This validation is done at the point where the `mysql::server` resource is
+# marked as complete. This is used because after returning success, the
+# service is still not quite ready.
#
# @api private
#
diff --git a/metadata.json b/metadata.json
index fd5e380..fe5cf9f 100644
--- a/metadata.json
+++ b/metadata.json
@@ -32,6 +32,10 @@
"name": "puppetlabs/yumrepo_core",
"version_requirement": ">= 2.0.0 < 3.0.0"
},
+ {
+ "name": "puppet/systemd",
+ "version_requirement": ">= 5.2.0 < 8.0.0"
+ },
{
"name": "puppet/epel",
"version_requirement": ">= 5.0.0 < 6.0.0"
@@ -61,26 +65,30 @@
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7",
- "8"
+ "8",
+ "9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
- "8"
+ "8",
+ "9"
]
},
{
"operatingsystem": "Rocky",
"operatingsystemrelease": [
- "8"
+ "8",
+ "9"
]
},
{
"operatingsystem": "FreeBSD",
"operatingsystemrelease": [
- "13"
+ "13",
+ "14"
]
}
],
diff --git a/spec/classes/galera_debian_hacks_spec.rb b/spec/classes/galera_debian_hacks_spec.rb
new file mode 100644
index 0000000..4f9da23
--- /dev/null
+++ b/spec/classes/galera_debian_hacks_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe 'galera::debian' do
+ let(:pre_condition) do
+ "class { 'galera':
+ cluster_name => 'testcluster',
+ galera_master => 'control1',
+ package_ensure => 'present',
+ status_password => 'nonempty'
+ }"
+ end
+
+ shared_examples_for 'galera workarounds on Debian and Ubuntu' do
+ context 'with default parameters' do
+ it { is_expected.to contain_file('/etc/mysql/puppet_debfix.cnf').with_content(%r{[mysqld]}) }
+ it {
+ is_expected.to contain_exec('clean_up_ubuntu').with(
+ command: 'service mysql stop',
+ path: '/usr/bin:/bin:/usr/sbin:/sbin',
+ refreshonly: true,
+ subscribe: 'Package[mysql-server]',
+ )
+ }
+ it { is_expected.to contain_file('/var/lib/mysql-install-tmp') }
+ it { is_expected.to contain_exec('fix_galera_config_errors_episode_I').with(refreshonly: true) }
+ it { is_expected.to contain_exec('fix_galera_config_errors_episode_II').with(refreshonly: true) }
+ it { is_expected.to contain_exec('fix_galera_config_errors_episode_III').with(refreshonly: true) }
+ it { is_expected.to contain_exec('fix_galera_config_errors_episode_IV').with(refreshonly: true) }
+ end
+ end
+
+ on_supported_os.each do |os, facts|
+ context "on #{os}" do # rubocop:disable RSpec/EmptyExampleGroup
+ let(:facts) do
+ facts
+ end
+
+ case facts[:osfamily]
+ when 'Debian'
+ it_configures 'galera workarounds on Debian and Ubuntu'
+ end
+ end
+ end
+end
diff --git a/spec/classes/galera_debian_spec.rb b/spec/classes/galera_debian_spec.rb
index 8bf5c64..7672735 100644
--- a/spec/classes/galera_debian_spec.rb
+++ b/spec/classes/galera_debian_spec.rb
@@ -1,31 +1,53 @@
require 'spec_helper'
-describe 'galera::debian' do
- let(:pre_condition) do
- "class { 'galera':
- cluster_name => 'testcluster',
- galera_master => 'control1',
- package_ensure => 'present',
- status_password => 'nonempty'
- }"
+describe 'galera' do
+ let(:params) do
+ {
+ bind_address: '10.2.2.1',
+ cluster_name: 'testcluster',
+ configure_firewall: true,
+ configure_repo: true,
+ deb_sysmaint_password: 'sysmaint',
+ galera_master: 'control1',
+ galera_servers: ['10.2.2.1'],
+ local_ip: '10.2.2.1',
+ mysql_port: 3306,
+ mysql_restart: false,
+ override_options: {},
+ package_ensure: 'present',
+ root_password: 'test',
+ status_password: 'nonempty',
+ vendor_type: 'percona',
+ vendor_version: '5.7',
+ wsrep_group_comm_port: 4567,
+ wsrep_inc_state_transfer_port: 4568,
+ wsrep_sst_method: 'rsync',
+ wsrep_state_transfer_port: 4444,
+ }
end
shared_examples_for 'galera on Debian' do
context 'with default parameters' do
- it { is_expected.to contain_file('/etc/mysql/puppet_debfix.cnf').with_content(%r{[mysqld]}) }
it {
- is_expected.to contain_exec('clean_up_ubuntu').with(
- command: 'service mysql stop',
- path: '/usr/bin:/bin:/usr/sbin:/sbin',
- refreshonly: true,
- subscribe: 'Package[mysql-server]',
+ is_expected.to contain_systemd__manage_unit('mysqlchk.socket').with(
+ socket_entry: {
+ 'ListenStream' => 9200,
+ 'Accept' => true,
+ },
)
}
- it { is_expected.to contain_file('/var/lib/mysql-install-tmp') }
- it { is_expected.to contain_exec('fix_galera_config_errors_episode_I').with(refreshonly: true) }
- it { is_expected.to contain_exec('fix_galera_config_errors_episode_II').with(refreshonly: true) }
- it { is_expected.to contain_exec('fix_galera_config_errors_episode_III').with(refreshonly: true) }
- it { is_expected.to contain_exec('fix_galera_config_errors_episode_IV').with(refreshonly: true) }
+ it { is_expected.to create_systemd__daemon_reload('mysqlchk.socket') }
+ it {
+ is_expected.to contain_systemd__manage_unit('mysqlchk@.service').with(
+ service_entry: {
+ 'User' => 'clustercheck',
+ 'Group' => 'clustercheck',
+ 'StandardInput' => 'socket',
+ 'ExecStart' => '/usr/local/bin/clustercheck',
+ },
+ )
+ }
+ it { is_expected.to create_systemd__daemon_reload('mysqlchk@.service') }
end
context 'when this node is the master' do
@@ -88,6 +110,32 @@
end
end
+ shared_examples_for 'galera on Debian 11 and older' do
+ context 'when installing percona' do
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: '',
+ log_on_success_operator: '=',
+ log_on_failure: nil,
+ )
+ }
+ end
+ context 'when specifying logging options' do
+ before(:each) do
+ params.merge!(status_log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ status_log_on_success_operator: '-=',
+ status_log_on_failure: 'USERID')
+ end
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ log_on_success_operator: '-=',
+ log_on_failure: 'USERID',
+ )
+ }
+ end
+ end
+
on_supported_os.each do |os, facts|
context "on #{os}" do # rubocop:disable RSpec/EmptyExampleGroup
let(:facts) do
@@ -96,7 +144,13 @@
case facts[:osfamily]
when 'Debian'
- it_configures 'galera on Debian'
+ if facts[:os]['name'] == 'Debian' and Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12') >= 0
+ it_configures 'galera on Debian'
+ elsif facts[:os]['name'] == 'Ubuntu' and Puppet::Util::Package.versioncmp(facts[:os]['release']['full'], '24.04') >= 0
+ it_configures 'galera on Debian'
+ else
+ it_configures 'galera on Debian 11 and older'
+ end
end
end
end
diff --git a/spec/classes/galera_freebsd_spec.rb b/spec/classes/galera_freebsd_spec.rb
new file mode 100644
index 0000000..d03c69a
--- /dev/null
+++ b/spec/classes/galera_freebsd_spec.rb
@@ -0,0 +1,70 @@
+require 'spec_helper'
+
+describe 'galera' do
+ let :params do
+ {
+ arbitrator_config_file: '/etc/default/garb',
+ arbitrator_package_name: 'galera-arbitrator',
+ arbitrator_service_name: 'garb',
+ bind_address: '10.2.2.1',
+ cluster_name: 'testcluster',
+ configure_firewall: true,
+ configure_repo: true,
+ deb_sysmaint_password: 'sysmaint',
+ galera_master: 'control1',
+ galera_servers: ['10.2.2.1'],
+ local_ip: '10.2.2.1',
+ mysql_port: 3306,
+ mysql_restart: false,
+ override_options: {},
+ root_password: 'test',
+ status_password: 'nonempty',
+ vendor_type: 'percona',
+ vendor_version: '5.7',
+ wsrep_group_comm_port: 4567,
+ wsrep_inc_state_transfer_port: 4568,
+ wsrep_sst_method: 'rsync',
+ wsrep_state_transfer_port: 4444,
+ }
+ end
+
+ shared_examples_for 'galera on FreeBSD' do
+ context 'when installing percona' do
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: '',
+ log_on_success_operator: '=',
+ log_on_failure: nil,
+ )
+ }
+ end
+
+ context 'when specifying logging options' do
+ before(:each) do
+ params.merge!(status_log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ status_log_on_success_operator: '-=',
+ status_log_on_failure: 'USERID')
+ end
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ log_on_success_operator: '-=',
+ log_on_failure: 'USERID',
+ )
+ }
+ end
+ end
+
+ on_supported_os.each do |os, facts|
+ context "on #{os}" do # rubocop:disable RSpec/EmptyExampleGroup
+ let(:facts) do
+ facts.merge({})
+ end
+
+ case facts[:osfamily]
+ when 'FreeBSD'
+ it_configures 'galera on FreeBSD'
+ end
+ end
+ end
+end
diff --git a/spec/classes/galera_init_spec.rb b/spec/classes/galera_init_spec.rb
index e43c566..9cabf99 100644
--- a/spec/classes/galera_init_spec.rb
+++ b/spec/classes/galera_init_spec.rb
@@ -53,14 +53,6 @@
it { is_expected.to contain_class('mysql::server') }
- it {
- is_expected.to contain_xinetd__service('mysqlchk').with(
- log_on_success: '',
- log_on_success_operator: '=',
- log_on_failure: nil,
- )
- }
-
it { is_expected.to contain_group('clustercheck').with(system: true) }
it {
is_expected.to contain_user('clustercheck').with(
@@ -267,19 +259,9 @@
it { is_expected.not_to contain_firewall('4567 galera accept tcp') }
end
- context 'when specifying logging options' do
- before(:each) do
- params.deep_merge!(status_log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
- status_log_on_success_operator: '-=',
- status_log_on_failure: 'USERID')
- end
- it {
- is_expected.to contain_xinetd__service('mysqlchk').with(
- log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
- log_on_success_operator: '-=',
- log_on_failure: 'USERID',
- )
- }
+ context 'when status_check=false' do
+ before(:each) { params.merge!(status_check: false) }
+ it { is_expected.not_to contain_class('galera::status') }
end
end
diff --git a/spec/classes/galera_redhat_spec.rb b/spec/classes/galera_redhat_spec.rb
index 9bd9140..d6fbc1d 100644
--- a/spec/classes/galera_redhat_spec.rb
+++ b/spec/classes/galera_redhat_spec.rb
@@ -35,6 +35,26 @@
it { is_expected.to contain_class('galera::redhat') }
it { is_expected.to contain_package(os_params[:p_additional_packages]).with(ensure: 'installed') }
it { is_expected.to contain_service('mysql@bootstrap') }
+ it {
+ is_expected.to contain_systemd__manage_unit('mysqlchk.socket').with(
+ socket_entry: {
+ 'ListenStream' => 9200,
+ 'Accept' => true,
+ },
+ )
+ }
+ it { is_expected.to create_systemd__daemon_reload('mysqlchk.socket') }
+ it {
+ is_expected.to contain_systemd__manage_unit('mysqlchk@.service').with(
+ service_entry: {
+ 'User' => 'clustercheck',
+ 'Group' => 'clustercheck',
+ 'StandardInput' => 'socket',
+ 'ExecStart' => '/usr/local/bin/clustercheck',
+ },
+ )
+ }
+ it { is_expected.to create_systemd__daemon_reload('mysqlchk@.service') }
end
context 'when node is the master' do
@@ -42,6 +62,20 @@
it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{systemctl start mysql@bootstrap.service}) }
end
+ context 'when status_port=12345' do
+ before(:each) do
+ params.merge!(status_port: 12_345)
+ end
+ it {
+ is_expected.to contain_systemd__manage_unit('mysqlchk.socket').with(
+ socket_entry: {
+ 'ListenStream' => 12_345,
+ 'Accept' => true,
+ },
+ )
+ }
+ end
+
context 'when installing mariadb' do
before(:each) { params.deep_merge!(vendor_type: 'mariadb', vendor_version: '10.3') }
@@ -50,10 +84,29 @@
end
end
- shared_examples_for 'galera on RedHat 6' do
- context 'when node is the master' do
- before(:each) { params.deep_merge!(galera_master: facts[:networking]['fqdn']) }
- it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{/etc/init.d/mysql bootstrap-pxc}) }
+ shared_examples_for 'galera on RedHat 8 and older' do
+ context 'when installing percona' do
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: '',
+ log_on_success_operator: '=',
+ log_on_failure: nil,
+ )
+ }
+ end
+ context 'when specifying logging options' do
+ before(:each) do
+ params.merge!(status_log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ status_log_on_success_operator: '-=',
+ status_log_on_failure: 'USERID')
+ end
+ it {
+ is_expected.to contain_xinetd__service('mysqlchk').with(
+ log_on_success: 'PID HOST USERID EXIT DURATION TRAFFIC',
+ log_on_success_operator: '-=',
+ log_on_failure: 'USERID',
+ )
+ }
end
end
@@ -71,10 +124,10 @@
case facts[:osfamily]
when 'RedHat'
- if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
+ if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '9') >= 0
it_configures 'galera on RedHat'
- elsif facts[:operatingsystemmajrelease] == '6'
- it_configures 'galera on RedHat 6'
+ else
+ it_configures 'galera on RedHat 8 and older'
end
end
end