Puppet4 propper support in the mysql module
* Adapt to Puppet 4 * Code cleanup Change-Id: I540ac66098434aea231aa7711e90f7e109ea3761 Partial-Bug: #1533359
This commit is contained in:
parent
af93a3a3eb
commit
64110deddc
@ -65,7 +65,7 @@ class mysql::config(
|
|||||||
fail('The ignore_db_dirs parameter is expected to be an array')
|
fail('The ignore_db_dirs parameter is expected to be an array')
|
||||||
}
|
}
|
||||||
|
|
||||||
if $custom_setup_class != "pacemaker_mysql" {
|
if $custom_setup_class != 'pacemaker_mysql' {
|
||||||
File {
|
File {
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => $root_group,
|
group => $root_group,
|
||||||
|
@ -16,7 +16,7 @@ class mysql::params {
|
|||||||
$port = 3306
|
$port = 3306
|
||||||
$etc_root_password = false
|
$etc_root_password = false
|
||||||
$ssl = false
|
$ssl = false
|
||||||
$server_id = delete(delete(delete("${::hostname}",'controller-'),'fuel-'),"node-")
|
$server_id = delete($::hostname, ['controller-', 'fuel-', 'node-'])
|
||||||
$service_provider = undef
|
$service_provider = undef
|
||||||
#TODO(bogdando) remove code duplication for galera and mysql manifests to openstack::db in 'I' release
|
#TODO(bogdando) remove code duplication for galera and mysql manifests to openstack::db in 'I' release
|
||||||
#Set buffer pool size to 30% of memory, but not greater than 10G
|
#Set buffer pool size to 30% of memory, but not greater than 10G
|
||||||
@ -52,7 +52,7 @@ class mysql::params {
|
|||||||
$service_name = 'mysql'
|
$service_name = 'mysql'
|
||||||
$client_package_name = 'MySQL-client'
|
$client_package_name = 'MySQL-client'
|
||||||
$client_version = '5.5.28_wsrep_23.7'
|
$client_version = '5.5.28_wsrep_23.7'
|
||||||
$server_package_name = 'MySQL-server'
|
$server_package_nam = 'MySQL-server'
|
||||||
$server_version = '5.5.28_wsrep_23.7'
|
$server_version = '5.5.28_wsrep_23.7'
|
||||||
$shared_package_name = 'MySQL-shared'
|
$shared_package_name = 'MySQL-shared'
|
||||||
$shared_version = '5.5.28_wsrep_23.7'
|
$shared_version = '5.5.28_wsrep_23.7'
|
||||||
|
@ -19,8 +19,8 @@ class mysql::python(
|
|||||||
) inherits mysql::params {
|
) inherits mysql::params {
|
||||||
|
|
||||||
package { 'python-mysqldb':
|
package { 'python-mysqldb':
|
||||||
name => $package_name,
|
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
|
name => $package_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ class mysql::ruby (
|
|||||||
) inherits mysql::params {
|
) inherits mysql::params {
|
||||||
|
|
||||||
package{ 'ruby_mysql':
|
package{ 'ruby_mysql':
|
||||||
name => $package_name,
|
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
|
name => $package_name,
|
||||||
provider => $package_provider,
|
provider => $package_provider,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class mysql::server (
|
|||||||
$server_id = $mysql::params::server_id,
|
$server_id = $mysql::params::server_id,
|
||||||
$rep_user = 'replicator',
|
$rep_user = 'replicator',
|
||||||
$rep_pass = 'replicant666',
|
$rep_pass = 'replicant666',
|
||||||
$replication_roles = "SELECT, PROCESS, FILE, SUPER, REPLICATION CLIENT, REPLICATION SLAVE, RELOAD",
|
$replication_roles = 'SELECT, PROCESS, FILE, SUPER, REPLICATION CLIENT, REPLICATION SLAVE, RELOAD',
|
||||||
$use_syslog = false,
|
$use_syslog = false,
|
||||||
$initscript_file = 'puppet:///modules/mysql/mysql-single.init',
|
$initscript_file = 'puppet:///modules/mysql/mysql-single.init',
|
||||||
$root_password = 'UNSET',
|
$root_password = 'UNSET',
|
||||||
@ -50,14 +50,14 @@ class mysql::server (
|
|||||||
$config_file_real = $mysql::params::config_file
|
$config_file_real = $mysql::params::config_file
|
||||||
}
|
}
|
||||||
|
|
||||||
class { 'mysql::password' :
|
class { '::mysql::password' :
|
||||||
root_password => $root_password,
|
root_password => $root_password,
|
||||||
old_root_password => $old_root_password,
|
old_root_password => $old_root_password,
|
||||||
etc_root_password => $etc_root_password,
|
etc_root_password => $etc_root_password,
|
||||||
config_file => $config_file_real,
|
config_file => $config_file_real,
|
||||||
}
|
}
|
||||||
|
|
||||||
class { 'mysql::config' :
|
class { '::mysql::config' :
|
||||||
bind_address => $bind_address,
|
bind_address => $bind_address,
|
||||||
use_syslog => $use_syslog,
|
use_syslog => $use_syslog,
|
||||||
custom_setup_class => $custom_setup_class,
|
custom_setup_class => $custom_setup_class,
|
||||||
@ -67,7 +67,7 @@ class mysql::server (
|
|||||||
|
|
||||||
Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'}
|
Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'}
|
||||||
if ($custom_setup_class == undef) {
|
if ($custom_setup_class == undef) {
|
||||||
class { 'mysql':
|
class { '::mysql':
|
||||||
package_name => $client_package_name,
|
package_name => $client_package_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class mysql::server (
|
|||||||
name => $package_name,
|
name => $package_name,
|
||||||
}
|
}
|
||||||
if $::operatingsystem == 'RedHat' {
|
if $::operatingsystem == 'RedHat' {
|
||||||
file { "/etc/init.d/mysqld":
|
file { '/etc/init.d/mysqld':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
source => $initscript_file,
|
source => $initscript_file,
|
||||||
mode => '0755',
|
mode => '0755',
|
||||||
@ -93,26 +93,31 @@ class mysql::server (
|
|||||||
}
|
}
|
||||||
Package['mysql-client'] -> Package['mysql-server']
|
Package['mysql-client'] -> Package['mysql-server']
|
||||||
|
|
||||||
|
$service_ensure = $enabled ? {
|
||||||
|
true => 'running',
|
||||||
|
default => 'stopped'
|
||||||
|
}
|
||||||
|
|
||||||
service { 'mysql':
|
service { 'mysql':
|
||||||
|
ensure => $service_ensure,
|
||||||
name => $service_name,
|
name => $service_name,
|
||||||
ensure => $enabled ? { true => 'running', default => 'stopped' },
|
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
require => Package['mysql-server'],
|
require => Package['mysql-server'],
|
||||||
provider => $service_provider,
|
provider => $service_provider,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($custom_setup_class == 'pacemaker_mysql') {
|
elsif ($custom_setup_class == 'pacemaker_mysql') {
|
||||||
class { 'mysql':
|
class { '::mysql':
|
||||||
package_name => $client_package_name,
|
package_name => $client_package_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['mysql-server'] -> Class['mysql::config']
|
Package['mysql-server'] -> Class['mysql::config']
|
||||||
Package['mysql-client'] -> Package['mysql-server']
|
Package['mysql-client'] -> Package['mysql-server']
|
||||||
|
|
||||||
$config_hash['custom_setup_class'] = $custom_setup_class
|
$mysql_config = merge($config_hash, { custom_setup_class => $custom_setup_class })
|
||||||
$allowed_hosts = '%'
|
$allowed_hosts = '%'
|
||||||
|
|
||||||
create_resources( 'class', { 'mysql::config' => $config_hash })
|
create_resources( 'class', { 'mysql::config' => $mysql_config })
|
||||||
Class['mysql::config'] -> Cs_resource["p_${service_name}"]
|
Class['mysql::config'] -> Cs_resource["p_${service_name}"]
|
||||||
|
|
||||||
if !defined(Package['mysql-client']) {
|
if !defined(Package['mysql-client']) {
|
||||||
@ -124,10 +129,10 @@ class mysql::server (
|
|||||||
package { 'mysql-server':
|
package { 'mysql-server':
|
||||||
name => $package_name,
|
name => $package_name,
|
||||||
} ->
|
} ->
|
||||||
exec { "create-mysql-table-if-missing":
|
exec { 'create-mysql-table-if-missing':
|
||||||
command => "/usr/bin/mysql_install_db --datadir=$mysql::params::datadir --user=mysql && chown -R mysql:mysql $mysql::params::datadir",
|
command => "/usr/bin/mysql_install_db --datadir=${mysql::params::datadir} --user=mysql && chown -R mysql:mysql ${mysql::params::datadir}",
|
||||||
path => '/bin:/usr/bin:/sbin:/usr/sbin',
|
path => '/bin:/usr/bin:/sbin:/usr/sbin',
|
||||||
unless => "test -d $mysql::params::datadir/mysql",
|
unless => "test -d ${mysql::params::datadir}/mysql",
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/tmp/repl_create.sql' :
|
file { '/tmp/repl_create.sql' :
|
||||||
@ -144,7 +149,7 @@ class mysql::server (
|
|||||||
source => 'puppet:///modules/mysql/ocf/ocf-mysql',
|
source => 'puppet:///modules/mysql/ocf/ocf-mysql',
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => 'root',
|
group => 'root',
|
||||||
mode => 0755,
|
mode => '0755',
|
||||||
require => File['/tmp/repl_create.sql'],
|
require => File['/tmp/repl_create.sql'],
|
||||||
} ->
|
} ->
|
||||||
install_ssh_keys {'root_ssh_key_for_mysql':
|
install_ssh_keys {'root_ssh_key_for_mysql':
|
||||||
@ -170,7 +175,6 @@ class mysql::server (
|
|||||||
exec { 'start_mysql_slave_on_second_controller':
|
exec { 'start_mysql_slave_on_second_controller':
|
||||||
command => "ssh -i /root/.ssh/id_rsa_mysql -o StrictHostKeyChecking=no root@${existing_slave} 'mysql -NBe \"start slave;\"'",
|
command => "ssh -i /root/.ssh/id_rsa_mysql -o StrictHostKeyChecking=no root@${existing_slave} 'mysql -NBe \"start slave;\"'",
|
||||||
unless => "mysql -NBe 'show slave status;' | grep -q ${rep_user}",
|
unless => "mysql -NBe 'show slave status;' | grep -q ${rep_user}",
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
### end hacks
|
### end hacks
|
||||||
@ -182,27 +186,42 @@ class mysql::server (
|
|||||||
primitive_type => 'mysql',
|
primitive_type => 'mysql',
|
||||||
cib => 'mysql',
|
cib => 'mysql',
|
||||||
complex_type => 'master',
|
complex_type => 'master',
|
||||||
ms_metadata => {'notify' => "true"},
|
ms_metadata => {
|
||||||
|
'notify' => true
|
||||||
|
},
|
||||||
parameters => {
|
parameters => {
|
||||||
'binary' => "/usr/bin/mysqld_safe",
|
'binary' => '/usr/bin/mysqld_safe',
|
||||||
'test_table' => 'mysql.user',
|
'test_table' => 'mysql.user',
|
||||||
'replication_user' => $rep_user,
|
'replication_user' => $rep_user,
|
||||||
'replication_passwd' => $rep_pass,
|
'replication_passwd' => $rep_pass,
|
||||||
'additional_parameters' => '"--init-file=/tmp/repl_create.sql"',
|
'additional_parameters' => '"--init-file=/tmp/repl_create.sql"',
|
||||||
},
|
},
|
||||||
operations => {
|
operations => {
|
||||||
'monitor' => { 'interval' => '20', 'timeout' => '30' },
|
'monitor' => {
|
||||||
'start' => { 'timeout' => '360' },
|
'interval' => '20',
|
||||||
'stop' => { 'timeout' => '360' },
|
'timeout' => '30'
|
||||||
'promote' => { 'timeout' => '360' },
|
},
|
||||||
'demote' => { 'timeout' => '360' },
|
'start' => {
|
||||||
'notify' => { 'timeout' => '360' },
|
'timeout' => '360'
|
||||||
|
},
|
||||||
|
'stop' => {
|
||||||
|
'timeout' => '360'
|
||||||
|
},
|
||||||
|
'promote' => {
|
||||||
|
'timeout' => '360'
|
||||||
|
},
|
||||||
|
'demote' => {
|
||||||
|
'timeout' => '360'
|
||||||
|
},
|
||||||
|
'notify' => {
|
||||||
|
'timeout' => '360'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}->
|
}->
|
||||||
|
|
||||||
service { 'mysql':
|
service { 'mysql':
|
||||||
name => "p_${service_name}",
|
|
||||||
ensure => 'running',
|
ensure => 'running',
|
||||||
|
name => "p_${service_name}",
|
||||||
enable => true,
|
enable => true,
|
||||||
require => [Package['mysql-server']],
|
require => [Package['mysql-server']],
|
||||||
provider => 'pacemaker',
|
provider => 'pacemaker',
|
||||||
@ -218,7 +237,7 @@ class mysql::server (
|
|||||||
}
|
}
|
||||||
elsif ($custom_setup_class == 'galera') {
|
elsif ($custom_setup_class == 'galera') {
|
||||||
Class['galera'] -> Class['mysql::server']
|
Class['galera'] -> Class['mysql::server']
|
||||||
class { 'galera':
|
class { '::galera':
|
||||||
cluster_name => $galera_cluster_name,
|
cluster_name => $galera_cluster_name,
|
||||||
primary_controller => $primary_controller,
|
primary_controller => $primary_controller,
|
||||||
node_address => $galera_node_address,
|
node_address => $galera_node_address,
|
||||||
@ -232,7 +251,7 @@ class mysql::server (
|
|||||||
}
|
}
|
||||||
elsif ($custom_setup_class == 'percona') {
|
elsif ($custom_setup_class == 'percona') {
|
||||||
Class['galera'] -> Class['mysql::server']
|
Class['galera'] -> Class['mysql::server']
|
||||||
class { 'galera':
|
class { '::galera':
|
||||||
cluster_name => $galera_cluster_name,
|
cluster_name => $galera_cluster_name,
|
||||||
primary_controller => $primary_controller,
|
primary_controller => $primary_controller,
|
||||||
node_address => $galera_node_address,
|
node_address => $galera_node_address,
|
||||||
@ -245,7 +264,7 @@ class mysql::server (
|
|||||||
}
|
}
|
||||||
} elsif ($custom_setup_class == 'percona_packages') {
|
} elsif ($custom_setup_class == 'percona_packages') {
|
||||||
Class['galera'] -> Class['mysql::server']
|
Class['galera'] -> Class['mysql::server']
|
||||||
class { 'galera':
|
class { '::galera':
|
||||||
cluster_name => $galera_cluster_name,
|
cluster_name => $galera_cluster_name,
|
||||||
primary_controller => $primary_controller,
|
primary_controller => $primary_controller,
|
||||||
node_address => $galera_node_address,
|
node_address => $galera_node_address,
|
||||||
@ -257,10 +276,7 @@ class mysql::server (
|
|||||||
use_percona => true,
|
use_percona => true,
|
||||||
use_percona_packages => true
|
use_percona_packages => true
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
require($custom_setup_class)
|
require($custom_setup_class)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ class mysql::server::account_security {
|
|||||||
ensure => 'absent',
|
ensure => 'absent',
|
||||||
require => Class['mysql::config'],
|
require => Class['mysql::config'],
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
database_user { [ 'root@127.0.0.1', "root@${::hostname}", "@${::hostname}", '@localhost', '@%' ]:
|
database_user { [ 'root@127.0.0.1', "root@${::hostname}", "@${::hostname}", '@localhost', '@%' ]:
|
||||||
|
@ -7,8 +7,8 @@ class mysql::server::monitor (
|
|||||||
Class['mysql::server'] -> Class['mysql::server::monitor']
|
Class['mysql::server'] -> Class['mysql::server::monitor']
|
||||||
|
|
||||||
database_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
database_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
||||||
password_hash => mysql_password($mysql_monitor_password),
|
|
||||||
ensure => present,
|
ensure => present,
|
||||||
|
password_hash => mysql_password($mysql_monitor_password),
|
||||||
}
|
}
|
||||||
|
|
||||||
database_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
database_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
||||||
|
Loading…
Reference in New Issue
Block a user