From 20b5983868da2aa196b884c6c2624d06c6a65aa3 Mon Sep 17 00:00:00 2001 From: Mykyta Koshykov Date: Thu, 4 Jun 2015 10:53:18 -0500 Subject: [PATCH] Initial Percona cluster support added This change adds two new custom_setup_class options to the mysql class. With this change, we now support 'percona' and 'percona_packages' to be passed to the mysql::server class that will cause percona to be used. This change adds the use_percona and use_percona_packages params to the existing galera class. The 'use_percona' option will cause the configuration to use the Linux distrubution classes for the Percona installation. This only works with Ubuntu. By setting both 'use_percona' and 'use_percona_packages' to true, the puppet configuration will use the Percona provided packages for installation. This assumes that the Percona packages are available to the system. Additionally tests have been added to the galera class to ensure that expected resources are configured for both the regular packages and the percona packages. By default, the existing galera configuration remains the same and assumes the use of existing packages. Partial blueprint: detach-components-from-controllers DocImpact Change-Id: I972698a8b2dae4caca6101db6d48bab405e40eae Co-Authored-By: Nikita Koshikov Co-Authored-By: Alex Schultz --- deployment/puppet/galera/.fixtures.yml | 8 + deployment/puppet/galera/.gitignore | 1 + deployment/puppet/galera/Gemfile | 22 +- deployment/puppet/galera/Rakefile | 21 +- deployment/puppet/galera/manifests/init.pp | 135 +++++++----- deployment/puppet/galera/manifests/params.pp | 65 ++++-- .../puppet/galera/spec/shared-examples.rb | 195 ++++++++++++++++++ .../puppet/galera/spec/shared_examples.rb | 5 - deployment/puppet/galera/spec/spec.opts | 6 + deployment/puppet/galera/spec/spec_helper.rb | 55 ++++- .../galera/spec/unit/classes/init_spec.rb | 89 ++++++++ .../puppet/galera/templates/wsrep.cnf.erb | 2 +- deployment/puppet/mysql/manifests/password.pp | 2 +- deployment/puppet/mysql/manifests/server.pp | 26 +++ .../modular/database/database.pp | 14 ++ 15 files changed, 552 insertions(+), 94 deletions(-) create mode 100644 deployment/puppet/galera/.fixtures.yml create mode 100644 deployment/puppet/galera/spec/shared-examples.rb delete mode 100644 deployment/puppet/galera/spec/shared_examples.rb create mode 100644 deployment/puppet/galera/spec/spec.opts create mode 100644 deployment/puppet/galera/spec/unit/classes/init_spec.rb diff --git a/deployment/puppet/galera/.fixtures.yml b/deployment/puppet/galera/.fixtures.yml new file mode 100644 index 0000000000..ec387eac83 --- /dev/null +++ b/deployment/puppet/galera/.fixtures.yml @@ -0,0 +1,8 @@ +fixtures: + forge_modules: + firewall: "puppetlabs/firewall" + stdlib: "puppetlabs/stdlib" + symlinks: + galera: "#{source_dir}" + pacemaker: "#{source_dir}/../pacemaker" + tweaks: "#{source_dir}/../tweaks" diff --git a/deployment/puppet/galera/.gitignore b/deployment/puppet/galera/.gitignore index 31a7379514..47d4c6c88d 100644 --- a/deployment/puppet/galera/.gitignore +++ b/deployment/puppet/galera/.gitignore @@ -3,3 +3,4 @@ pkg/ .DS_Store coverage/ +fixtures/modules/ diff --git a/deployment/puppet/galera/Gemfile b/deployment/puppet/galera/Gemfile index ef4cbcf97b..749947b37e 100644 --- a/deployment/puppet/galera/Gemfile +++ b/deployment/puppet/galera/Gemfile @@ -1,10 +1,20 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', '~> 0.3.2' - gem 'rake', '~> 10.1.1', :require => false - gem 'rspec-puppet', :require => false +group :development, :unit_tests do + gem 'rake', :require => false + gem 'rspec-core', '3.1.7', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'puppet-lint', :require => false + gem 'simplecov', :require => false + gem 'puppet_facts', :require => false + gem 'json', :require => false +end + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/deployment/puppet/galera/Rakefile b/deployment/puppet/galera/Rakefile index d5ccdb06fc..e3be95b0b8 100644 --- a/deployment/puppet/galera/Rakefile +++ b/deployment/puppet/galera/Rakefile @@ -1,17 +1,10 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] -desc "Run puppet in noop mode and check for syntax errors." -task :validate do - Dir['manifests/**/*.pp'].each do |manifest| - sh "puppet parser validate --noop #{manifest}" - end - Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ - end - Dir['templates/**/*.erb'].each do |template| - sh "erb -P -x -T '-' #{template} | ruby -c" - end -end +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/deployment/puppet/galera/manifests/init.pp b/deployment/puppet/galera/manifests/init.pp index e853706083..077e5f408f 100644 --- a/deployment/puppet/galera/manifests/init.pp +++ b/deployment/puppet/galera/manifests/init.pp @@ -48,42 +48,58 @@ # (optional) The method for state snapshot transfer between nodes # Defaults to xtrabackup-v2 # xtrabackup, xtrabackup-v2, mysqldump are supported - +# +# [*use_percona*] +# Boolean. Set this value to true if you want to use percona instead of +# the mysql packages. +# +# [*use_percona_packages*] +# Boolean. Set this value to true to use the Percona distrubuted packages. +# This requires that these packages are available via a repository for the +# system at install time. NOTE: use_percona must be set to true for this to +# be used. +# class galera ( $cluster_name = 'openstack', $primary_controller = false, $node_address = $ipaddress_eth0, $setup_multiple_gcomm = true, $skip_name_resolve = false, - $node_addresses = $ipaddress_eth0, + $node_addresses = [ $ipaddress_eth0 ], $use_syslog = false, $gcomm_port = '4567', $status_check = true, $wsrep_sst_method = 'xtrabackup-v2', $wsrep_sst_password = undef, + $use_percona = false, + $use_percona_packages = false, ) { include galera::params - anchor {'galera': } + validate_array($node_addresses) + validate_bool($use_percona) + validate_bool($use_percona_packages) - $mysql_user = $::galera::params::mysql_user - $mysql_password = $wsrep_sst_password ? { + anchor {'database-cluster': } + + $mysql_user = $::galera::params::mysql_user + $mysql_password = $wsrep_sst_password ? { undef => $::galera::params::mysql_password, default => $wsrep_sst_password } - $libgalera_prefix = $::galera::params::libgalera_prefix - $mysql_buffer_pool_size = $::galera::params::mysql_buffer_pool_size - $mysql_log_file_size = $::galera::params::mysql_log_file_size - $max_connections = $::galera::params::max_connections - $table_open_cache = $::galera::params::table_open_cache - $key_buffer_size = $::galera::params::key_buffer_size + $libgalera_prefix = $::galera::params::libgalera_prefix + $mysql_buffer_pool_size = $::galera::params::mysql_buffer_pool_size + $mysql_log_file_size = $::galera::params::mysql_log_file_size + $max_connections = $::galera::params::max_connections + $table_open_cache = $::galera::params::table_open_cache + $key_buffer_size = $::galera::params::key_buffer_size $myisam_sort_buffer_size = $::galera::params::myisam_sort_buffer_size - $wait_timeout = $::galera::params::wait_timeout - $open_files_limit= $::galera::params::open_files_limit - $datadir=$::mysql::params::datadir - $service_name=$::galera::params::service_name - $innodb_flush_method=$::galera::params::innodb_flush_method + $wait_timeout = $::galera::params::wait_timeout + $open_files_limit = $::galera::params::open_files_limit + $datadir = $::mysql::params::datadir + $service_name = $::galera::params::service_name + $innodb_flush_method = $::galera::params::innodb_flush_method package { ['wget', 'perl']: @@ -94,7 +110,24 @@ class galera ( file { '/etc/my.cnf': ensure => present, content => template('galera/my.cnf.erb'), - # before => File['mysql-wss-ocf'] + } + + if ($use_percona and $::operatingsystem == 'Ubuntu') { + # Disable service autostart + file { '/usr/sbin/policy-rc.d': + ensure => present, + content => inline_template("#!/bin/sh\nexit 101\n"), + mode => '0755', + before => Package['MySQL-server'] + } + + #FIXME: + #Remove this after https://bugs.launchpad.net/bugs/1461304 will be fixed + file {'/etc/apt/apt.conf.d/99tmp': + ensure => present, + content => inline_template("Dpkg::Options {\n\t\"--force-overwrite\";\n}"), + before => Package['MySQL-server'] + } } package { 'mysql-client': @@ -109,13 +142,16 @@ class galera ( before => Package['MySQL-server'] } - package { $::galera::params::libaio_package: - ensure => present, - before => Package['galera', 'MySQL-server'] + if !($use_percona) { + package { $::galera::params::libaio_package: + ensure => present, + before => Package['galera', 'MySQL-server'] + } } package { 'galera': ensure => present, + name => $::galera::params::libgalera_package, before => Package['MySQL-server'] } @@ -156,15 +192,12 @@ class galera ( ensure => present, mode => '0644', require => Package['MySQL-server'], - # before => File['mysql-wss-ocf'] } if $primary_controller { - $galera_socket = $::osfamily ? { - 'RedHat' => '/var/lib/mysql/mysql.sock', - 'Debian' => '/var/run/mysqld/mysqld.sock', - } + $galera_socket = $::galera::params::database_socket + # TODO(bogdando) move to extras as a wrapper class cs_resource { "p_${service_name}": ensure => present, @@ -173,9 +206,9 @@ class galera ( primitive_type => 'mysql-wss', complex_type => 'clone', parameters => { - 'test_user' => "${mysql_user}", - 'test_passwd' => "${mysql_password}", - 'socket' => "${galera_socket}", + 'test_user' => $mysql_user, + 'test_passwd' => $mysql_password, + 'socket' => $galera_socket, }, operations => { 'monitor' => { @@ -190,29 +223,15 @@ class galera ( }, }, } - Anchor['galera'] -> - #File['mysql-wss-ocf'] -> - Cs_resource["p_${service_name}"] -> - Service['mysql'] -> - Exec['wait-for-synced-state'] + Anchor['database-cluster'] -> + Cs_resource["p_${service_name}"] -> + Service['mysql'] -> + Exec['wait-for-synced-state'] } else { - Anchor['galera'] -> - #File['mysql-wss-ocf'] -> - Service['mysql'] + Anchor['database-cluster'] -> + Service['mysql'] } - #file { 'mysql-wss-ocf': - # path => '/usr/lib/ocf/resource.d/fuel/mysql-wss', - # mode => '0755', - # owner => root, - # group => root, - # source => 'puppet:///modules/galera/ocf/mysql-wss', - #} - - #File<| title == 'ocf-fuel-path' |> -> File['mysql-wss-ocf'] - - # Package['MySQL-server', 'galera'] -> File['mysql-wss-ocf'] - tweaks::ubuntu_service_override { 'mysql': package_name => 'MySQL-server', } @@ -224,9 +243,11 @@ class galera ( provider => 'pacemaker', } - Service['mysql'] -> Anchor['galera-done'] + Service['mysql'] -> Anchor['database-cluster-done'] + # lint:ignore:quoted_booleans if $::galera_gcomm_empty == 'true' { + # lint:endignore #FIXME(bogdando): dirtyhack to pervert imperative puppet nature. if $::mysql_log_file_size_real != $mysql_log_file_size { # delete MySQL ib_logfiles, if log file size does not match the one @@ -279,6 +300,20 @@ class galera ( tries => 60, } + if ($use_percona and $::operatingsystem == 'Ubuntu') { + #Clean tmp files: + exec { 'rm-policy-rc.d': + command => '/bin/rm /usr/sbin/policy-rc.d', + } + exec {'rm-99tmp': + command => '/bin/rm /etc/apt/apt.conf.d/99tmp', + } + Exec['wait-for-synced-state'] -> + Exec['rm-policy-rc.d'] + Exec['wait-for-synced-state'] -> + Exec['rm-99tmp'] + } + File['/tmp/wsrep-init-file'] -> Service['mysql'] -> Exec['wait-initial-sync'] -> @@ -286,5 +321,5 @@ class galera ( Exec ['rm-init-file'] Package['MySQL-server'] ~> Exec['wait-initial-sync'] - anchor {'galera-done': } + anchor {'database-cluster-done': } } diff --git a/deployment/puppet/galera/manifests/params.pp b/deployment/puppet/galera/manifests/params.pp index e12bc41556..854702b0f8 100644 --- a/deployment/puppet/galera/manifests/params.pp +++ b/deployment/puppet/galera/manifests/params.pp @@ -35,21 +35,58 @@ class galera::params { $innodb_flush_method = 'O_DIRECT' $max_connections = '4096' - case $::osfamily { - 'RedHat': { - $libaio_package = 'libaio' - $mysql_server_name = 'MySQL-server-wsrep' - $mysql_client_name = 'MySQL-client-wsrep' - $libgalera_prefix = '/usr/lib64' + if ($::galera::use_percona) { + case $::osfamily { + 'RedHat': { + if ($::galera::use_percona_packages) { + $mysql_server_name = 'Percona-XtraDB-Cluster-server-56' + $mysql_client_name = 'Percona-XtraDB-Cluster-client-56' + $libgalera_package = 'Percona-XtraDB-Cluster-galera-3' + $libgalera_prefix = '/usr/lib64/galera3' + } else { + fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only supports Debian when not using the Percona packages") + } + $database_socket = '/var/lib/mysql/mysql.sock' + } + 'Debian': { + if ($::galera::use_percona_packages) { + $mysql_server_name = 'percona-xtradb-cluster-server-5.6' + $mysql_client_name = 'percona-xtradb-cluster-client-5.6' + $libgalera_package = 'percona-xtradb-cluster-galera-3.x' + $libgalera_prefix = '/usr/lib/galera3' + } else { + $mysql_server_name = 'percona-xtradb-cluster-server-5.5' + $mysql_client_name = 'percona-xtradb-cluster-client-5.5' + $libgalera_package = 'percona-xtradb-cluster-galera-2.x' + $libgalera_prefix = '/usr/lib' + } + $database_socket = '/var/run/mysqld/mysqld.sock' + } + default: { + fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian") + } } - 'Debian': { - $libaio_package = 'libaio1' - $mysql_server_name = 'mysql-server-wsrep-5.6' - $mysql_client_name = 'mysql-client-5.6' - $libgalera_prefix = '/usr/lib' - } - default: { - fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian") + } else { + case $::osfamily { + 'RedHat': { + $libaio_package = 'libaio' + $mysql_server_name = 'MySQL-server-wsrep' + $mysql_client_name = 'MySQL-client-wsrep' + $libgalera_package = 'galera' + $libgalera_prefix = '/usr/lib64/galera' + $database_socket = '/var/lib/mysql/mysql.sock' + } + 'Debian': { + $libaio_package = 'libaio1' + $mysql_server_name = 'mysql-server-wsrep-5.6' + $mysql_client_name = 'mysql-client-5.6' + $libgalera_package = 'galera' + $libgalera_prefix = '/usr/lib/galera' + $database_socket = '/var/run/mysqld/mysqld.sock' + } + default: { + fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian") + } } } diff --git a/deployment/puppet/galera/spec/shared-examples.rb b/deployment/puppet/galera/spec/shared-examples.rb new file mode 100644 index 0000000000..c4cfc1f5a8 --- /dev/null +++ b/deployment/puppet/galera/spec/shared-examples.rb @@ -0,0 +1,195 @@ +# this is a basic example that just checks there are no puppet syntax issues or +# compile errors +shared_examples 'compile' do + it { + should compile + } +end + +# this example checks all of the expected items for the galera::init class +shared_examples 'galera-init' do |params| + params = {} if params.nil? + it { + should contain_class('galera') + should contain_class('galera::params') + should contain_tweaks__ubuntu_service_override('mysql') + } + it_behaves_like 'compile' + it_behaves_like 'test-packages', params + it_behaves_like 'test-files', params + it_behaves_like 'test-services', params + it_behaves_like 'test-primary-controller', params + it_behaves_like 'test-backup', params +end + +# this example checks for the existance of the expected files for the galera +# class +shared_examples 'test-files' do |params| + params = {} if params.nil? + + p = { + :use_percona_packages => false + }.merge(params) + + let (:params) { p } + + it { + should contain_file('/etc/my.cnf') + should contain_file('/etc/mysql') + should contain_file('/etc/mysql/conf.d') + should contain_file('/etc/init.d/mysql') + should contain_file('/etc/mysql/conf.d/wsrep.cnf') + should contain_file('/tmp/wsrep-init-file') + if params[:use_percona_packages] and facts[:operatingsystem] == 'Ubuntu' + should contain_file('/usr/sbin/policy-rc.d') + should contain_file('/etc/apt/apt.conf.d/99tmp') + end + } +end + +# this example checks for the definition of the specific packages expected for +# the galera class +shared_examples 'test-packages' do |params| + params = {} if params.nil? + + p = { + :wsrep_sst_method => 'xtrabackup-v2', + :use_percona => false, + :use_percona_packages => false + }.merge(params) + + let (:params) { p } + + if params[:use_percona] + if params[:use_percona_packages] + it_behaves_like 'percona-packages' + else + it_behaves_like 'percona-distro-packages' + end + else + it_behaves_like 'mysql-packages' + end + +end + +# this example checks for the percona packages +shared_examples 'percona-packages' do |params| + it { + case facts[:operatingsystem] + when 'Ubuntu' + mysql_server_name = 'percona-xtradb-cluster-server-5.6' + mysql_client_name = 'percona-xtradb-cluster-client-5.6' + libgalera_package = 'percona-xtradb-cluster-galera-3.x' + when 'CentOS' + mysql_server_name = 'Percona-XtraDB-Cluster-server-56' + mysql_client_name = 'Percona-XtraDB-Cluster-client-56' + libgalera_package = 'Percona-XtraDB-Cluster-galera-3' + end + should contain_package('MySQL-server').with_name(mysql_server_name) + should contain_package('mysql-client').with_name(mysql_client_name) + should contain_package('galera').with_name(libgalera_package) + } +end + +# this example checks for the percona packages +shared_examples 'percona-distro-packages' do |params| + it { + case facts[:operatingsystem] + when 'Ubuntu' + mysql_server_name = 'percona-xtradb-cluster-server-5.5' + mysql_client_name = 'percona-xtradb-cluster-client-5.5' + libgalera_package = 'percona-xtradb-cluster-galera-2.x' + should contain_package('MySQL-server').with_name(mysql_server_name) + should contain_package('mysql-client').with_name(mysql_client_name) + should contain_package('galera').with_name(libgalera_package) + when 'CentOS' + should raise_error(Puppet::Error, /Unsupported/) + end + } +end + +# this example checks for the use of the mysql classes +shared_examples 'mysql-packages' do + it { + case facts[:operatingsystem] + when 'Ubuntu' + mysql_server_name = 'mysql-server-wsrep-5.6' + mysql_client_name = 'mysql-client-5.6' + libgalera_package = 'galera' + libaio_package = 'libaio1' + when 'CentOS' + mysql_server_name = 'MySQL-server-wsrep' + mysql_client_name = 'MySQL-client-wsrep' + libgalera_package = 'galera' + libaio_package = 'libaio' + end + should contain_package('MySQL-server').with_name(mysql_server_name) + should contain_package('mysql-client').with_name(mysql_client_name) + should contain_package('galera').with_name(libgalera_package) + should contain_package(libaio_package) + } +end + +# this example checks for the expected services for the galera class +shared_examples 'test-services' do |params| + params = {} if params.nil? + + p = {}.merge(params) + + let (:params) { p } + + it { + should contain_service('mysql').with({ + 'ensure' => 'running', + 'name' => 'p_mysql', + 'provider' => 'pacemaker' + }) + } +end + +# this example checks for the cluster resource definitions for a primary +# controller. This should probably not live in the galera class. +shared_examples 'test-primary-controller' do |params| + params = {} if params.nil? + + p = { + :primary_controller => false + }.merge(params) + + let (:params) { p } + + it { + if params[:primary_controller] + should contain_cs_resource('p_mysql') + else + should_not contain_cs_resource('p_mysql') + end + } +end + +# this example checks for the catalog items around the backup option +shared_examples 'test-backup' do |params| + params = {} if params.nil? + + p = { + :wsrep_sst_method => 'xtrabackup-v2', + }.merge(params) + + let (:params) { p } + + if p.has_key?(:wsrep_sst_method) and ['xtrabackup', 'xtrabackup-v2'].include?(p[:wsrep_sst_method]) + it { + should contain_firewall('101 xtrabackup').with_port(4444) + should contain_package('percona-xtrabackup') + should contain_file('/etc/mysql/conf.d/wsrep.cnf').with_content(/xtrabackup/) + } + else + it { + should_not contain_firewall('101 xtrabackup').with_port(4444) + should_not contain_package('percona-xtrabackup') + should_not contain_file('/etc/mysql/conf.d/wsrep.cnf').with_content(/xtrabackup/) + } + end +end + +# vim: set ts=2 sw=2 et : diff --git a/deployment/puppet/galera/spec/shared_examples.rb b/deployment/puppet/galera/spec/shared_examples.rb deleted file mode 100644 index d92156a361..0000000000 --- a/deployment/puppet/galera/spec/shared_examples.rb +++ /dev/null @@ -1,5 +0,0 @@ -shared_examples_for "a Puppet::Error" do |description| - it "with message matching #{description.inspect}" do - expect { should have_class_count(1) }.to raise_error(Puppet::Error, description) - end -end diff --git a/deployment/puppet/galera/spec/spec.opts b/deployment/puppet/galera/spec/spec.opts new file mode 100644 index 0000000000..91cd6427ed --- /dev/null +++ b/deployment/puppet/galera/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/deployment/puppet/galera/spec/spec_helper.rb b/deployment/puppet/galera/spec/spec_helper.rb index 66411593e8..b4ad724f23 100644 --- a/deployment/puppet/galera/spec/spec_helper.rb +++ b/deployment/puppet/galera/spec/spec_helper.rb @@ -1,6 +1,55 @@ +require 'rubygems' require 'puppetlabs_spec_helper/module_spec_helper' -RSpec.configure do |c| - c.alias_it_should_behave_like_to :it_configures, 'configures' - c.alias_it_should_behave_like_to :it_raises, 'raises' +module Facts + def self.fqdn + 'server.example.com' + end + + def self.hostname + self.fqdn.split('.').first + end + + def self.ipaddress + '10.0.0.1' + end + + def self.ubuntu_facts + { + :fqdn => fqdn, + :hostname => hostname, + :processorcount => '4', + :memorysize_mb => '32138.66', + :memorysize => '31.39 GB', + :kernel => 'Linux', + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '14.04', + :lsbdistid => 'Ubuntu', + :concat_basedir => '/tmp/', + :ipaddress_eth0 => ipaddress + } + end + + def self.centos_facts + { + :fqdn => fqdn, + :hostname => hostname, + :processorcount => '4', + :memorysize_mb => '32138.66', + :memorysize => '31.39 GB', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + :operatingsystemrelease => '6.5', + :lsbdistid => 'CentOS', + :concat_basedir => '/tmp/', + :ipaddress_eth0 => ipaddress + } + end end + +# Generage coverage report at the end of a run +at_exit { RSpec::Puppet::Coverage.report! } + +# vim: set ts=2 sw=2 et : diff --git a/deployment/puppet/galera/spec/unit/classes/init_spec.rb b/deployment/puppet/galera/spec/unit/classes/init_spec.rb new file mode 100644 index 0000000000..255df2d6f4 --- /dev/null +++ b/deployment/puppet/galera/spec/unit/classes/init_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper.rb' +require 'shared-examples' + +describe 'galera', :type => :class do + context 'Defaults on CentOS' do + let(:facts) { Facts.centos_facts } + it_behaves_like 'galera-init' + end + context 'Defaults on Ubuntu' do + let(:facts) { Facts.ubuntu_facts } + it_behaves_like 'galera-init' + end + + context 'Percona on CentOS' do + let(:facts) { Facts.centos_facts } + p = { + :use_percona => true, + :use_percona_packages => false + } + # we only test compile and packages because this configuration should + # result in a puppet error indicating no support + it_behaves_like 'compile', p + it_behaves_like 'test-packages', p + end + context 'Percona on Ubuntu' do + let(:facts) { Facts.ubuntu_facts } + p = { + :use_percona => true, + :use_percona_packages => false + } + it_behaves_like 'galera-init', p + + # these are extra things that should be expected on Ubuntu to work around + # the package installation on Ubuntu + let(:params) { p } + it { + should contain_exec('rm-policy-rc.d') + should contain_exec('rm-99tmp') + } + end + + context 'Percona Packages on CentOS' do + let(:facts) { Facts.centos_facts } + p = { + :use_percona => true, + :use_percona_packages => true + } + it_behaves_like 'galera-init', p + end + context 'Percona Packages on Ubuntu' do + let(:facts) { Facts.ubuntu_facts } + p = { + :use_percona => true, + :use_percona_packages => true + } + it_behaves_like 'galera-init', p + + # these are extra things that should be expected on Ubuntu to work around + # the package installation on Ubuntu + let(:params) { p } + it { + should contain_exec('rm-policy-rc.d') + should contain_exec('rm-99tmp') + } + end + + context 'Primary Controller on CentOS' do + let(:facts) { Facts.centos_facts } + p = { :primary_controller => true } + it_behaves_like 'galera-init', p + end + context 'Primary Controller on Ubuntu' do + let(:facts) { Facts.ubuntu_facts } + p = { :primary_controller => true } + it_behaves_like 'galera-init', p + end + + context 'wsrep_sst_method mysqldump on CentOS' do + let(:facts) { Facts.centos_facts } + p = { :wsrep_sst_method => 'undef' } + it_behaves_like 'galera-init', p + end + context 'wsrep_sst_method mysqldump on Ubuntu' do + let(:facts) { Facts.ubuntu_facts } + p = { :wsrep_sst_method => 'mysqldump' } + it_behaves_like 'galera-init', p + end +end +# vim: set ts=2 sw=2 et : diff --git a/deployment/puppet/galera/templates/wsrep.cnf.erb b/deployment/puppet/galera/templates/wsrep.cnf.erb index 7346317f80..bf6a20a93b 100644 --- a/deployment/puppet/galera/templates/wsrep.cnf.erb +++ b/deployment/puppet/galera/templates/wsrep.cnf.erb @@ -51,7 +51,7 @@ wsrep_cluster_address="gcomm://<%= @node_addresses.collect {|ip| ip + ':' + @gco <% else -%> wsrep_cluster_address="gcomm://<%= @node_addresses.first %>:<%= @gcomm_port.to_s %>?pc.wait_prim=no" <% end -%> -wsrep_provider=<%= @libgalera_prefix %>/galera/libgalera_smm.so +wsrep_provider=<%= @libgalera_prefix %>/libgalera_smm.so wsrep_cluster_name="<%= @cluster_name -%>" wsrep_slave_threads=<%= [[@processorcount.to_i*2, 4].max, 12].min %> diff --git a/deployment/puppet/mysql/manifests/password.pp b/deployment/puppet/mysql/manifests/password.pp index 886e6b8c12..18afe38f7d 100644 --- a/deployment/puppet/mysql/manifests/password.pp +++ b/deployment/puppet/mysql/manifests/password.pp @@ -45,7 +45,7 @@ class mysql::password ( File['mysql_password'] -> Database_grant <| provider=='mysql' |> File['mysql_password'] -> Database_user <| provider=='mysql' |> - Anchor <| title == 'galera' |> -> Class['mysql::password'] -> Anchor <| title == 'galera-done' |> + Anchor <| title == 'database-cluster' |> -> Class['mysql::password'] -> Anchor <| title == 'database-cluster-done' |> Exec <| title == 'wait-for-synced-state' |> -> Exec['set_mysql_rootpw'] Exec <| title == 'wait-initial-sync' |> -> Exec['set_mysql_rootpw'] diff --git a/deployment/puppet/mysql/manifests/server.pp b/deployment/puppet/mysql/manifests/server.pp index c92bca7391..86d1f3e8ba 100644 --- a/deployment/puppet/mysql/manifests/server.pp +++ b/deployment/puppet/mysql/manifests/server.pp @@ -226,6 +226,32 @@ class mysql::server ( wsrep_sst_password => $root_password, } + } + elsif ($custom_setup_class == 'percona') { + Class['galera'] -> Class['mysql::server'] + class { 'galera': + cluster_name => $galera_cluster_name, + primary_controller => $primary_controller, + node_address => $galera_node_address, + node_addresses => $galera_nodes, + skip_name_resolve => $mysql_skip_name_resolve, + use_syslog => $use_syslog, + wsrep_sst_password => $root_password, + use_percona => true, + } + } elsif ($custom_setup_class == 'percona_packages') { + Class['galera'] -> Class['mysql::server'] + class { 'galera': + cluster_name => $galera_cluster_name, + primary_controller => $primary_controller, + node_address => $galera_node_address, + node_addresses => $galera_nodes, + skip_name_resolve => $mysql_skip_name_resolve, + use_syslog => $use_syslog, + wsrep_sst_password => $root_password, + use_percona => true, + use_percona_packages => true + } } else { diff --git a/deployment/puppet/osnailyfacter/modular/database/database.pp b/deployment/puppet/osnailyfacter/modular/database/database.pp index 7dfaf2ca6f..53522a5dab 100644 --- a/deployment/puppet/osnailyfacter/modular/database/database.pp +++ b/deployment/puppet/osnailyfacter/modular/database/database.pp @@ -76,6 +76,20 @@ if $mysql_database_enabled { command => '/bin/ln -sf /etc/mysql/conf.d/password.cnf /root/.my.cnf', } + if ($custom_mysql_setup_class == 'percona_packages' and $::osfamily == 'RedHat') { + # This is a work around to prevent the conflict between the + # MySQL-shared-wsrep package (included as a dependency for MySQL-python) and + # the Percona shared package Percona-XtraDB-Cluster-shared-56. They both + # provide the libmysql client libraries. Since we are requiring the + # installation of the Percona package here before mysql::python, the python + # client is happy and the server installation won't fail due to the + # installation of our shared package + package { 'Percona-XtraDB-Cluster-shared-56': + ensure => 'present', + before => Class['mysql::python'], + } + } + class { 'openstack::galera::status': status_user => $status_user, status_password => $status_password,