This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class galera( | |
$primary_fqdn = false, | |
) { | |
######################################## | |
# REPOSITORY AND PACKAGE INSTALLATION | |
######################################## | |
contain galera::repo | |
Package { 'mariadb-galera-server': | |
ensure => 'present', | |
} | |
Package { 'galera': | |
ensure => 'present', | |
} | |
Package { 'mariadb-client': | |
ensure => 'present', | |
} | |
Class['galera::repo'] -> Package['mariadb-galera-server'] | |
Class['galera::repo'] -> Package['mariadb-client'] | |
Class['galera::repo'] -> Package['galera'] | |
service { 'mysql': | |
enable => true, | |
require => [Package['mariadb-galera-server'], Package['galera'], Package['mariadb-client']], | |
} | |
######################################## | |
# ROOT AND DEBIAN-SYS-MAINT PASSWORD | |
######################################## | |
$root_password = 'deinemudda' | |
$debian_sys_maint_password = 'd6FMei5OrsamXeQz' | |
exec { 'debian-sys-maint': | |
command => "/usr/bin/mysql -u root mysql -e \"SET PASSWORD FOR 'debian-sys-maint'@'localhost' = PASSWORD('$debian_sys_maint_password'); FLUSH PRIVILEGES;\"", | |
require => Service['mysql'], | |
onlyif => "/usr/bin/mysql -u root"; | |
} | |
exec { 'root_password': | |
command => "/usr/bin/mysql -u root mysql -e \"UPDATE user SET password=PASSWORD('$root_password') WHERE User='root'; FLUSH PRIVILEGES;\"", | |
onlyif => "/usr/bin/mysql -u root", | |
require => Exec['debian-sys-maint'], | |
} | |
class debian_sys_maint_settings { | |
$ini_defaults = { | |
'path' => '/etc/mysql/debian.cnf', | |
} | |
$ini_values = { | |
'client' => { | |
'password' => $debian_sys_maint_password, | |
}, | |
'mysql_upgrade' => { | |
'password' => $debian_sys_maint_password, | |
} | |
} | |
create_ini_settings($ini_values, $ini_defaults) | |
} | |
contain galera::debian_sys_maint_settings | |
Exec['debian-sys-maint'] -> Class['galera::debian_sys_maint_settings'] | |
######################################## | |
# MYSQLD CONFIGURATION | |
######################################## | |
class ini_settings { | |
$ini_defaults = { | |
'path' => '/etc/mysql/my.cnf', | |
} | |
$ini_values = { | |
'mysqld' => { | |
'query_cache_size' => '0', | |
'binlog_format' => 'ROW', | |
'default-storage-engine' => 'innodb', | |
'innodb_autoinc_lock_mode' => '2', | |
'query_cache_type' => '0', | |
'bind-address' => '0.0.0.0', | |
'wsrep_provider' => '/usr/lib/galera/libgalera_smm.so', | |
'wsrep_cluster_name' => 'test_cluster', | |
'wsrep_cluster_address' => 'gcomm://10.0.0.11,10.0.0.12,10.0.0.13', | |
'wsrep_sst_method' => 'rsync', | |
'wsrep_node_address' => $ipaddress_eth0, | |
'wsrep_node_name' => $hostname, | |
} | |
} | |
create_ini_settings($ini_values, $ini_defaults) | |
} | |
contain galera::ini_settings | |
Service['mysql'] -> Class['galera::ini_settings'] | |
######################################## | |
# START SERVICE | |
######################################## | |
exec { 'mysql_stop': | |
command => '/usr/sbin/service mysql stop', | |
require => [ | |
Class['galera::ini_settings'], | |
Class['galera::debian_sys_maint_settings'], | |
Exec['root_password'] | |
] | |
} | |
exec { 'mysql_start': | |
command => '/usr/sbin/service mysql start', | |
require => Exec['mysql_stop'], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment