Merge pull request #568 from enovance/issue/567/emilien
database/sql: boostrap mysql on Red Hat / CentOS
This commit is contained in:
commit
bcdc407228
@ -65,12 +65,103 @@ class cloud::database::sql (
|
|||||||
|
|
||||||
$gcomm_definition = inline_template('<%= @galera_internal_ips.join(",") + "?pc.wait_prim=no" -%>')
|
$gcomm_definition = inline_template('<%= @galera_internal_ips.join(",") + "?pc.wait_prim=no" -%>')
|
||||||
|
|
||||||
|
# Specific to the Galera master node
|
||||||
if $::hostname == $galera_master_name {
|
if $::hostname == $galera_master_name {
|
||||||
$mysql_service_name = 'mysql-bootstrap'
|
|
||||||
|
$mysql_root_password_real = $mysql_root_password
|
||||||
|
|
||||||
|
# OpenStack DB
|
||||||
|
class { 'keystone::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'keystone',
|
||||||
|
user => $keystone_db_user,
|
||||||
|
password => $keystone_db_password,
|
||||||
|
host => $keystone_db_host,
|
||||||
|
allowed_hosts => $keystone_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'glance::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'glance',
|
||||||
|
user => $glance_db_user,
|
||||||
|
password => $glance_db_password,
|
||||||
|
host => $glance_db_host,
|
||||||
|
allowed_hosts => $glance_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'nova::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'nova',
|
||||||
|
user => $nova_db_user,
|
||||||
|
password => $nova_db_password,
|
||||||
|
host => $nova_db_host,
|
||||||
|
allowed_hosts => $nova_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'cinder::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'cinder',
|
||||||
|
user => $cinder_db_user,
|
||||||
|
password => $cinder_db_password,
|
||||||
|
host => $cinder_db_host,
|
||||||
|
allowed_hosts => $cinder_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'neutron::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'neutron',
|
||||||
|
user => $neutron_db_user,
|
||||||
|
password => $neutron_db_password,
|
||||||
|
host => $neutron_db_host,
|
||||||
|
allowed_hosts => $neutron_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'heat::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'heat',
|
||||||
|
user => $heat_db_user,
|
||||||
|
password => $heat_db_password,
|
||||||
|
host => $heat_db_host,
|
||||||
|
allowed_hosts => $heat_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
class { 'trove::db::mysql':
|
||||||
|
mysql_module => '2.2',
|
||||||
|
dbname => 'trove',
|
||||||
|
user => $trove_db_user,
|
||||||
|
password => $trove_db_password,
|
||||||
|
host => $trove_db_host,
|
||||||
|
allowed_hosts => $trove_db_allowed_hosts,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Monitoring DB
|
||||||
|
mysql_database { 'monitoring':
|
||||||
|
ensure => 'present',
|
||||||
|
charset => 'utf8',
|
||||||
|
collate => 'utf8_unicode_ci',
|
||||||
|
require => File['/root/.my.cnf']
|
||||||
|
}
|
||||||
|
mysql_user { "${galera_clustercheck_dbuser}@localhost":
|
||||||
|
ensure => 'present',
|
||||||
|
# can not change password in clustercheck script
|
||||||
|
password_hash => mysql_password($galera_clustercheck_dbpassword),
|
||||||
|
require => File['/root/.my.cnf']
|
||||||
|
}
|
||||||
|
mysql_grant { "${galera_clustercheck_dbuser}@localhost/monitoring":
|
||||||
|
ensure => 'present',
|
||||||
|
options => ['GRANT'],
|
||||||
|
privileges => ['ALL'],
|
||||||
|
table => 'monitoring.*',
|
||||||
|
user => "${galera_clustercheck_dbuser}@localhost",
|
||||||
|
}
|
||||||
|
|
||||||
|
Database_user<<| |>>
|
||||||
} else {
|
} else {
|
||||||
$mysql_service_name = 'mysql'
|
# NOTE(sileht): Only the master must create the password
|
||||||
|
# into the database, slave nodes must just use the password.
|
||||||
|
# The one in the database have been retrieved via galera.
|
||||||
|
file { "${::root_home}/.my.cnf":
|
||||||
|
content => "[client]\nuser=root\nhost=localhost\npassword=${mysql_root_password}\n",
|
||||||
|
owner => 'root',
|
||||||
|
mode => '0600',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Specific to Red Hat or Debian systems:
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
# Specific to Red Hat
|
# Specific to Red Hat
|
||||||
@ -79,6 +170,12 @@ class cloud::database::sql (
|
|||||||
$wsrep_provider = '/usr/lib64/galera/libgalera_smm.so'
|
$wsrep_provider = '/usr/lib64/galera/libgalera_smm.so'
|
||||||
$mysql_server_config_file = '/etc/my.cnf'
|
$mysql_server_config_file = '/etc/my.cnf'
|
||||||
|
|
||||||
|
if $::hostname == $galera_master_name {
|
||||||
|
$mysql_service_name = 'mysql-bootstrap'
|
||||||
|
} else {
|
||||||
|
$mysql_service_name = 'mariadb'
|
||||||
|
}
|
||||||
|
|
||||||
$dirs = [ '/var/run/mysqld', '/var/log/mysql' ]
|
$dirs = [ '/var/run/mysqld', '/var/log/mysql' ]
|
||||||
|
|
||||||
file { $dirs:
|
file { $dirs:
|
||||||
@ -87,6 +184,18 @@ class cloud::database::sql (
|
|||||||
before => Service['mysqld'],
|
before => Service['mysqld'],
|
||||||
owner => 'mysql'
|
owner => 'mysql'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# In Red Hat, the package does not perform the mysql db installation.
|
||||||
|
# We need to do this manually.
|
||||||
|
# Note: in MariaDB repository, package perform this action in post-install,
|
||||||
|
# but MariaDB is not packaged for Red Hat / CentOS 7 in MariaDB repository.
|
||||||
|
exec { 'bootstrap-mysql':
|
||||||
|
command => '/usr/bin/mysql_install_db --rpm --user=mysql',
|
||||||
|
unless => 'test -d /var/lib/mysql/mysql',
|
||||||
|
notify => Service['mysqld'],
|
||||||
|
require => [Package['mysql-server'], File[$mysql_server_config_file]]
|
||||||
|
}
|
||||||
|
|
||||||
} # RedHat
|
} # RedHat
|
||||||
'Debian': {
|
'Debian': {
|
||||||
# Specific to Debian / Ubuntu
|
# Specific to Debian / Ubuntu
|
||||||
@ -95,6 +204,12 @@ class cloud::database::sql (
|
|||||||
$wsrep_provider = '/usr/lib/galera/libgalera_smm.so'
|
$wsrep_provider = '/usr/lib/galera/libgalera_smm.so'
|
||||||
$mysql_server_config_file = '/etc/mysql/my.cnf'
|
$mysql_server_config_file = '/etc/mysql/my.cnf'
|
||||||
|
|
||||||
|
if $::hostname == $galera_master_name {
|
||||||
|
$mysql_service_name = 'mysql-bootstrap'
|
||||||
|
} else {
|
||||||
|
$mysql_service_name = 'mysql'
|
||||||
|
}
|
||||||
|
|
||||||
mysql_user { 'debian-sys-maint@localhost':
|
mysql_user { 'debian-sys-maint@localhost':
|
||||||
ensure => 'present',
|
ensure => 'present',
|
||||||
password_hash => mysql_password($mysql_sys_maint_password),
|
password_hash => mysql_password($mysql_sys_maint_password),
|
||||||
@ -152,7 +267,7 @@ class cloud::database::sql (
|
|||||||
package_name => $mysql_server_package_name,
|
package_name => $mysql_server_package_name,
|
||||||
service_name => $mysql_service_name,
|
service_name => $mysql_service_name,
|
||||||
override_options => { 'mysqld' => { 'bind-address' => $api_eth } },
|
override_options => { 'mysqld' => { 'bind-address' => $api_eth } },
|
||||||
root_password => $mysql_root_password,
|
root_password => $mysql_root_password_real,
|
||||||
notify => Service['xinetd'],
|
notify => Service['xinetd'],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,93 +284,6 @@ class cloud::database::sql (
|
|||||||
package_name => $mysql_client_package_name,
|
package_name => $mysql_client_package_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if $::hostname == $galera_master_name {
|
|
||||||
|
|
||||||
# OpenStack DB
|
|
||||||
class { 'keystone::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'keystone',
|
|
||||||
user => $keystone_db_user,
|
|
||||||
password => $keystone_db_password,
|
|
||||||
host => $keystone_db_host,
|
|
||||||
allowed_hosts => $keystone_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
class { 'glance::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'glance',
|
|
||||||
user => $glance_db_user,
|
|
||||||
password => $glance_db_password,
|
|
||||||
host => $glance_db_host,
|
|
||||||
allowed_hosts => $glance_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
class { 'nova::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'nova',
|
|
||||||
user => $nova_db_user,
|
|
||||||
password => $nova_db_password,
|
|
||||||
host => $nova_db_host,
|
|
||||||
allowed_hosts => $nova_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
class { 'cinder::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'cinder',
|
|
||||||
user => $cinder_db_user,
|
|
||||||
password => $cinder_db_password,
|
|
||||||
host => $cinder_db_host,
|
|
||||||
allowed_hosts => $cinder_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
class { 'neutron::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'neutron',
|
|
||||||
user => $neutron_db_user,
|
|
||||||
password => $neutron_db_password,
|
|
||||||
host => $neutron_db_host,
|
|
||||||
allowed_hosts => $neutron_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
class { 'heat::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'heat',
|
|
||||||
user => $heat_db_user,
|
|
||||||
password => $heat_db_password,
|
|
||||||
host => $heat_db_host,
|
|
||||||
allowed_hosts => $heat_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
class { 'trove::db::mysql':
|
|
||||||
mysql_module => '2.2',
|
|
||||||
dbname => 'trove',
|
|
||||||
user => $trove_db_user,
|
|
||||||
password => $trove_db_password,
|
|
||||||
host => $trove_db_host,
|
|
||||||
allowed_hosts => $trove_db_allowed_hosts,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Monitoring DB
|
|
||||||
mysql_database { 'monitoring':
|
|
||||||
ensure => 'present',
|
|
||||||
charset => 'utf8',
|
|
||||||
collate => 'utf8_unicode_ci',
|
|
||||||
require => File['/root/.my.cnf']
|
|
||||||
}
|
|
||||||
mysql_user { "${galera_clustercheck_dbuser}@localhost":
|
|
||||||
ensure => 'present',
|
|
||||||
# can not change password in clustercheck script
|
|
||||||
password_hash => mysql_password($galera_clustercheck_dbpassword),
|
|
||||||
require => File['/root/.my.cnf']
|
|
||||||
}
|
|
||||||
mysql_grant { "${galera_clustercheck_dbuser}@localhost/monitoring":
|
|
||||||
ensure => 'present',
|
|
||||||
options => ['GRANT'],
|
|
||||||
privileges => ['ALL'],
|
|
||||||
table => 'monitoring.*',
|
|
||||||
user => "${galera_clustercheck_dbuser}@localhost",
|
|
||||||
}
|
|
||||||
|
|
||||||
Database_user<<| |>>
|
|
||||||
} # if $::hostname == $galera_master
|
|
||||||
|
|
||||||
# Haproxy http monitoring
|
# Haproxy http monitoring
|
||||||
file_line { 'mysqlchk-in-etc-services':
|
file_line { 'mysqlchk-in-etc-services':
|
||||||
|
@ -71,14 +71,13 @@ describe 'cloud::database::sql' do
|
|||||||
it 'configure mysql galera server' do
|
it 'configure mysql galera server' do
|
||||||
should contain_class('mysql::client').with(
|
should contain_class('mysql::client').with(
|
||||||
:package_name => platform_params[:mysql_client_package_name]
|
:package_name => platform_params[:mysql_client_package_name]
|
||||||
)
|
)
|
||||||
|
|
||||||
should contain_class('mysql::server').with(
|
should contain_class('mysql::server').with(
|
||||||
:package_name => platform_params[:mysql_server_package_name],
|
:package_name => platform_params[:mysql_server_package_name],
|
||||||
:root_password => params[:mysql_root_password],
|
|
||||||
:override_options => { 'mysqld' => { 'bind-address' => '10.0.0.1' } },
|
:override_options => { 'mysqld' => { 'bind-address' => '10.0.0.1' } },
|
||||||
:notify => 'Service[xinetd]'
|
:notify => 'Service[xinetd]'
|
||||||
)
|
)
|
||||||
|
|
||||||
should contain_file(platform_params[:mysql_server_config_file]).with_content(/^wsrep_cluster_name\s*= "galera_cluster"$/)
|
should contain_file(platform_params[:mysql_server_config_file]).with_content(/^wsrep_cluster_name\s*= "galera_cluster"$/)
|
||||||
should contain_file(platform_params[:mysql_server_config_file]).with_content(/^wsrep_node_address\s*= "#{params[:api_eth]}"$/)
|
should contain_file(platform_params[:mysql_server_config_file]).with_content(/^wsrep_node_address\s*= "#{params[:api_eth]}"$/)
|
||||||
@ -107,6 +106,15 @@ describe 'cloud::database::sql' do
|
|||||||
facts.merge!( :hostname => 'os-ci-test1' )
|
facts.merge!( :hostname => 'os-ci-test1' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'configure mysql server' do
|
||||||
|
should contain_class('mysql::server').with(
|
||||||
|
:package_name => platform_params[:mysql_server_package_name],
|
||||||
|
:root_password => 'secrete',
|
||||||
|
:override_options => { 'mysqld' => { 'bind-address' => '10.0.0.1' } },
|
||||||
|
:notify => 'Service[xinetd]'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
it 'configure keystone database' do
|
it 'configure keystone database' do
|
||||||
should contain_class('keystone::db::mysql').with(
|
should contain_class('keystone::db::mysql').with(
|
||||||
:mysql_module => '2.2',
|
:mysql_module => '2.2',
|
||||||
@ -191,6 +199,20 @@ describe 'cloud::database::sql' do
|
|||||||
)
|
)
|
||||||
end # configure monitoring database
|
end # configure monitoring database
|
||||||
end # configure databases on the galera master server
|
end # configure databases on the galera master server
|
||||||
|
|
||||||
|
context 'Bootstrap MySQL database on RedHat plaforms' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'RedHat' )
|
||||||
|
end
|
||||||
|
it 'configure mysql database' do
|
||||||
|
should contain_exec('bootstrap-mysql').with(
|
||||||
|
:command => '/usr/bin/mysql_install_db --rpm --user=mysql',
|
||||||
|
:unless => "test -d /var/lib/mysql/mysql",
|
||||||
|
:notify => 'Service[mysqld]'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end # openstack database sql
|
end # openstack database sql
|
||||||
|
|
||||||
context 'on Debian platforms' do
|
context 'on Debian platforms' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user