Migrate mysql backend to use openstacklib::db::mysql
Implements: blueprint commmon-openstack-database-resource Change-Id: I1120a27a7c0bbec8d69d01d232d7de1d387703dd
This commit is contained in:
@@ -5,7 +5,8 @@ fixtures:
|
|||||||
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
|
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
|
||||||
'mysql':
|
'mysql':
|
||||||
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
|
repo: 'git://github.com/puppetlabs/puppetlabs-mysql.git'
|
||||||
ref: 'origin/0.x'
|
ref: 'origin/2.x'
|
||||||
|
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
|
||||||
'postgresql':
|
'postgresql':
|
||||||
repo: "git://github.com/puppetlabs/puppet-postgresql.git"
|
repo: "git://github.com/puppetlabs/puppet-postgresql.git"
|
||||||
ref: '2.5.0'
|
ref: '2.5.0'
|
||||||
|
@@ -13,6 +13,6 @@ dependency 'puppetlabs/cinder', '>=4.0.0 <5.0.0'
|
|||||||
dependency 'puppetlabs/glance', '>=4.0.0 <5.0.0'
|
dependency 'puppetlabs/glance', '>=4.0.0 <5.0.0'
|
||||||
dependency 'puppetlabs/inifile', '>=1.0.0 <2.0.0'
|
dependency 'puppetlabs/inifile', '>=1.0.0 <2.0.0'
|
||||||
dependency 'puppetlabs/keystone', '>=4.0.0 <5.0.0'
|
dependency 'puppetlabs/keystone', '>=4.0.0 <5.0.0'
|
||||||
dependency 'puppetlabs/mysql', '>=0.9.0 <3.0.0'
|
|
||||||
dependency 'puppetlabs/rabbitmq', '>=2.0.2 <4.0.0'
|
dependency 'puppetlabs/rabbitmq', '>=2.0.2 <4.0.0'
|
||||||
dependency 'puppetlabs/stdlib', '>=3.2.0'
|
dependency 'puppetlabs/stdlib', '>=3.2.0'
|
||||||
|
dependency 'stackforge/openstacklib', '>=5.0.0'
|
||||||
|
@@ -74,7 +74,6 @@ Limitations
|
|||||||
|
|
||||||
* Supports libvirt, xenserver and vmware compute drivers.
|
* Supports libvirt, xenserver and vmware compute drivers.
|
||||||
* Tested on EL and Debian derivatives.
|
* Tested on EL and Debian derivatives.
|
||||||
* The Nova Openstack service depends on a sqlalchemy database. If you are using puppetlabs-mysql to achieve this, there is a parameter called mysql_module that can be used to swap between the two supported versions: 0.9 and 2.2. This is needed because the puppetlabs-mysql module was rewritten and the custom type names have changed between versions.
|
|
||||||
|
|
||||||
Development
|
Development
|
||||||
-----------
|
-----------
|
||||||
|
@@ -36,9 +36,7 @@
|
|||||||
# Defaults to 'localzone'
|
# Defaults to 'localzone'
|
||||||
#
|
#
|
||||||
# [*mysql_module*]
|
# [*mysql_module*]
|
||||||
# (optional) Mysql puppet module version to use. Tested versions
|
# (optional) Deprecated. Does nothing.
|
||||||
# are 0.9 and 2.2.
|
|
||||||
# Defaults to '0.9'
|
|
||||||
#
|
#
|
||||||
class nova::db::mysql(
|
class nova::db::mysql(
|
||||||
$password,
|
$password,
|
||||||
@@ -48,7 +46,7 @@ class nova::db::mysql(
|
|||||||
$charset = 'utf8',
|
$charset = 'utf8',
|
||||||
$collate = 'utf8_unicode_ci',
|
$collate = 'utf8_unicode_ci',
|
||||||
$allowed_hosts = undef,
|
$allowed_hosts = undef,
|
||||||
$mysql_module = '0.9',
|
$mysql_module = undef,
|
||||||
$cluster_id = undef
|
$cluster_id = undef
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -56,44 +54,19 @@ class nova::db::mysql(
|
|||||||
warning('The cluster_id parameter is deprecated and has no effect.')
|
warning('The cluster_id parameter is deprecated and has no effect.')
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mysql_module >= 2.2) {
|
if $mysql_module {
|
||||||
mysql::db { $dbname:
|
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
|
||||||
user => $user,
|
|
||||||
password => $password,
|
|
||||||
host => $host,
|
|
||||||
charset => $charset,
|
|
||||||
collate => $collate,
|
|
||||||
require => Class['mysql::server'],
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
require 'mysql::python'
|
|
||||||
|
|
||||||
mysql::db { $dbname:
|
|
||||||
user => $user,
|
|
||||||
password => $password,
|
|
||||||
host => $host,
|
|
||||||
charset => $charset,
|
|
||||||
require => Class['mysql::config'],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the db instance before openstack-nova if its installed
|
::openstacklib::db::mysql { 'nova':
|
||||||
Mysql::Db[$dbname] -> Anchor<| title == 'nova-start' |>
|
user => $user,
|
||||||
Mysql::Db[$dbname] ~> Exec<| title == 'nova-db-sync' |>
|
password_hash => mysql_password($password),
|
||||||
|
dbname => $dbname,
|
||||||
# Check allowed_hosts to avoid duplicate resource declarations
|
host => $host,
|
||||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
charset => $charset,
|
||||||
$real_allowed_hosts = delete($allowed_hosts,$host)
|
collate => $collate,
|
||||||
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
|
allowed_hosts => $allowed_hosts,
|
||||||
$real_allowed_hosts = $allowed_hosts
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if $real_allowed_hosts {
|
::Openstacklib::Db::Mysql['nova'] ~> Exec<| title == 'nova-db-sync' |>
|
||||||
nova::db::mysql::host_access { $real_allowed_hosts:
|
|
||||||
user => $user,
|
|
||||||
password => $password,
|
|
||||||
database => $dbname,
|
|
||||||
mysql_module => $mysql_module,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
# db/allowed_hosts.pp
|
|
||||||
define nova::db::mysql::host_access ($user, $password, $database, $mysql_module = '0.9') {
|
|
||||||
if ($mysql_module >= 2.2) {
|
|
||||||
mysql_user { "${user}@${name}":
|
|
||||||
password_hash => mysql_password($password),
|
|
||||||
require => Mysql_database[$database],
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_grant { "${user}@${name}/${database}.*":
|
|
||||||
privileges => ['ALL'],
|
|
||||||
options => ['GRANT'],
|
|
||||||
table => "${database}.*",
|
|
||||||
require => Mysql_user["${user}@${name}"],
|
|
||||||
user => "${user}@${name}"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
database_user { "${user}@${name}":
|
|
||||||
password_hash => mysql_password($password),
|
|
||||||
provider => 'mysql',
|
|
||||||
require => Database[$database],
|
|
||||||
}
|
|
||||||
database_grant { "${user}@${name}/${database}":
|
|
||||||
# TODO figure out which privileges to grant.
|
|
||||||
privileges => 'all',
|
|
||||||
provider => 'mysql',
|
|
||||||
require => Database_user["${user}@${name}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -235,9 +235,7 @@
|
|||||||
# Defaults to '/bin/false'.
|
# Defaults to '/bin/false'.
|
||||||
#
|
#
|
||||||
# [*mysql_module*]
|
# [*mysql_module*]
|
||||||
# (optional) Mysql module version to use. Tested versions
|
# (optional) Deprecated. Does nothing.
|
||||||
# are 0.9 and 2.2
|
|
||||||
# Defaults to '0.9'
|
|
||||||
#
|
#
|
||||||
# [*notification_driver*]
|
# [*notification_driver*]
|
||||||
# (optional) Driver or drivers to handle sending notifications.
|
# (optional) Driver or drivers to handle sending notifications.
|
||||||
@@ -323,12 +321,12 @@ class nova(
|
|||||||
$use_syslog = false,
|
$use_syslog = false,
|
||||||
$log_facility = 'LOG_USER',
|
$log_facility = 'LOG_USER',
|
||||||
$install_utilities = true,
|
$install_utilities = true,
|
||||||
$mysql_module = '0.9',
|
|
||||||
$notification_driver = [],
|
$notification_driver = [],
|
||||||
$notification_topics = 'notifications',
|
$notification_topics = 'notifications',
|
||||||
$notify_api_faults = false,
|
$notify_api_faults = false,
|
||||||
$notify_on_state_change = undef,
|
$notify_on_state_change = undef,
|
||||||
# DEPRECATED PARAMETERS
|
# DEPRECATED PARAMETERS
|
||||||
|
$mysql_module = undef,
|
||||||
# this is how to query all resources from our clutser
|
# this is how to query all resources from our clutser
|
||||||
$nova_cluster_id = undef,
|
$nova_cluster_id = undef,
|
||||||
$sql_connection = false,
|
$sql_connection = false,
|
||||||
@@ -337,6 +335,10 @@ class nova(
|
|||||||
$os_region_name = undef,
|
$os_region_name = undef,
|
||||||
) inherits nova::params {
|
) inherits nova::params {
|
||||||
|
|
||||||
|
if $mysql_module {
|
||||||
|
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
|
||||||
|
}
|
||||||
|
|
||||||
if $nova_cluster_id {
|
if $nova_cluster_id {
|
||||||
warning('The nova_cluster_id parameter is deprecated and has no effect.')
|
warning('The nova_cluster_id parameter is deprecated and has no effect.')
|
||||||
}
|
}
|
||||||
@@ -510,12 +512,8 @@ class nova(
|
|||||||
# that may need to be collected from a remote host
|
# that may need to be collected from a remote host
|
||||||
if $database_connection_real {
|
if $database_connection_real {
|
||||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||||
if ($mysql_module >= 2.2) {
|
require 'mysql::bindings'
|
||||||
require 'mysql::bindings'
|
require 'mysql::bindings::python'
|
||||||
require 'mysql::bindings::python'
|
|
||||||
} else {
|
|
||||||
require 'mysql::python'
|
|
||||||
}
|
|
||||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||||
|
|
||||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||||
|
@@ -20,11 +20,10 @@ describe 'nova::db::mysql' do
|
|||||||
required_params
|
required_params
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_mysql__db('nova').with(
|
it { should contain_openstacklib__db__mysql('nova').with(
|
||||||
:user => 'nova',
|
:user => 'nova',
|
||||||
:password => 'qwerty',
|
:password_hash => '*AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||||
:charset => 'utf8',
|
:charset => 'utf8'
|
||||||
:require => "Class[Mysql::Config]"
|
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ describe 'nova::db::mysql' do
|
|||||||
{ :charset => 'latin1' }.merge(required_params)
|
{ :charset => 'latin1' }.merge(required_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
|
it { should contain_openstacklib__db__mysql('nova').with_charset(params[:charset]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -47,11 +46,10 @@ describe 'nova::db::mysql' do
|
|||||||
required_params
|
required_params
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_mysql__db('nova').with(
|
it { should contain_openstacklib__db__mysql('nova').with(
|
||||||
:user => 'nova',
|
:user => 'nova',
|
||||||
:password => 'qwerty',
|
:password_hash => '*AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||||
:charset => 'utf8',
|
:charset => 'utf8'
|
||||||
:require => "Class[Mysql::Config]"
|
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ describe 'nova::db::mysql' do
|
|||||||
{ :charset => 'latin1' }.merge(required_params)
|
{ :charset => 'latin1' }.merge(required_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
|
it { should contain_openstacklib__db__mysql('nova').with_charset(params[:charset]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,16 +73,6 @@ describe 'nova::db::mysql' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it {should_not contain_nova__db__mysql__host_access("127.0.0.1").with(
|
|
||||||
:user => 'nova',
|
|
||||||
:password => 'novapass',
|
|
||||||
:database => 'nova'
|
|
||||||
)}
|
|
||||||
it {should contain_nova__db__mysql__host_access("%").with(
|
|
||||||
:user => 'nova',
|
|
||||||
:password => 'novapass',
|
|
||||||
:database => 'nova'
|
|
||||||
)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "overriding allowed_hosts param to string" do
|
describe "overriding allowed_hosts param to string" do
|
||||||
@@ -98,11 +86,6 @@ describe 'nova::db::mysql' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it {should contain_nova__db__mysql__host_access("192.168.1.1").with(
|
|
||||||
:user => 'nova',
|
|
||||||
:password => 'novapass2',
|
|
||||||
:database => 'nova'
|
|
||||||
)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "overriding allowed_hosts param equals to host param " do
|
describe "overriding allowed_hosts param equals to host param " do
|
||||||
@@ -116,10 +99,5 @@ describe 'nova::db::mysql' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it {should_not contain_nova__db__mysql__host_access("127.0.0.1").with(
|
|
||||||
:user => 'nova',
|
|
||||||
:password => 'novapass2',
|
|
||||||
:database => 'nova'
|
|
||||||
)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user