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'
|
||||
'mysql':
|
||||
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':
|
||||
repo: "git://github.com/puppetlabs/puppet-postgresql.git"
|
||||
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/inifile', '>=1.0.0 <2.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/stdlib', '>=3.2.0'
|
||||
dependency 'stackforge/openstacklib', '>=5.0.0'
|
||||
|
@@ -74,7 +74,6 @@ Limitations
|
||||
|
||||
* Supports libvirt, xenserver and vmware compute drivers.
|
||||
* 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
|
||||
-----------
|
||||
|
@@ -36,9 +36,7 @@
|
||||
# Defaults to 'localzone'
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql puppet module version to use. Tested versions
|
||||
# are 0.9 and 2.2.
|
||||
# Defaults to '0.9'
|
||||
# (optional) Deprecated. Does nothing.
|
||||
#
|
||||
class nova::db::mysql(
|
||||
$password,
|
||||
@@ -48,7 +46,7 @@ class nova::db::mysql(
|
||||
$charset = 'utf8',
|
||||
$collate = 'utf8_unicode_ci',
|
||||
$allowed_hosts = undef,
|
||||
$mysql_module = '0.9',
|
||||
$mysql_module = undef,
|
||||
$cluster_id = undef
|
||||
) {
|
||||
|
||||
@@ -56,44 +54,19 @@ class nova::db::mysql(
|
||||
warning('The cluster_id parameter is deprecated and has no effect.')
|
||||
}
|
||||
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql::db { $dbname:
|
||||
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'],
|
||||
}
|
||||
if $mysql_module {
|
||||
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
|
||||
}
|
||||
|
||||
# Create the db instance before openstack-nova if its installed
|
||||
Mysql::Db[$dbname] -> Anchor<| title == 'nova-start' |>
|
||||
Mysql::Db[$dbname] ~> Exec<| title == 'nova-db-sync' |>
|
||||
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
||||
$real_allowed_hosts = delete($allowed_hosts,$host)
|
||||
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
|
||||
$real_allowed_hosts = $allowed_hosts
|
||||
::openstacklib::db::mysql { 'nova':
|
||||
user => $user,
|
||||
password_hash => mysql_password($password),
|
||||
dbname => $dbname,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
collate => $collate,
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
if $real_allowed_hosts {
|
||||
nova::db::mysql::host_access { $real_allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
mysql_module => $mysql_module,
|
||||
}
|
||||
}
|
||||
::Openstacklib::Db::Mysql['nova'] ~> Exec<| title == 'nova-db-sync' |>
|
||||
}
|
||||
|
@@ -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'.
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql module version to use. Tested versions
|
||||
# are 0.9 and 2.2
|
||||
# Defaults to '0.9'
|
||||
# (optional) Deprecated. Does nothing.
|
||||
#
|
||||
# [*notification_driver*]
|
||||
# (optional) Driver or drivers to handle sending notifications.
|
||||
@@ -323,12 +321,12 @@ class nova(
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$install_utilities = true,
|
||||
$mysql_module = '0.9',
|
||||
$notification_driver = [],
|
||||
$notification_topics = 'notifications',
|
||||
$notify_api_faults = false,
|
||||
$notify_on_state_change = undef,
|
||||
# DEPRECATED PARAMETERS
|
||||
$mysql_module = undef,
|
||||
# this is how to query all resources from our clutser
|
||||
$nova_cluster_id = undef,
|
||||
$sql_connection = false,
|
||||
@@ -337,6 +335,10 @@ class nova(
|
||||
$os_region_name = undef,
|
||||
) 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 {
|
||||
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
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
}
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
@@ -20,11 +20,10 @@ describe 'nova::db::mysql' do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { should contain_mysql__db('nova').with(
|
||||
:user => 'nova',
|
||||
:password => 'qwerty',
|
||||
:charset => 'utf8',
|
||||
:require => "Class[Mysql::Config]"
|
||||
it { should contain_openstacklib__db__mysql('nova').with(
|
||||
:user => 'nova',
|
||||
:password_hash => '*AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:charset => 'utf8'
|
||||
)}
|
||||
end
|
||||
|
||||
@@ -33,7 +32,7 @@ describe 'nova::db::mysql' do
|
||||
{ :charset => 'latin1' }.merge(required_params)
|
||||
end
|
||||
|
||||
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
|
||||
it { should contain_openstacklib__db__mysql('nova').with_charset(params[:charset]) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,11 +46,10 @@ describe 'nova::db::mysql' do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { should contain_mysql__db('nova').with(
|
||||
:user => 'nova',
|
||||
:password => 'qwerty',
|
||||
:charset => 'utf8',
|
||||
:require => "Class[Mysql::Config]"
|
||||
it { should contain_openstacklib__db__mysql('nova').with(
|
||||
:user => 'nova',
|
||||
:password_hash => '*AA1420F182E88B9E5F874F6FBE7459291E8F4601',
|
||||
:charset => 'utf8'
|
||||
)}
|
||||
end
|
||||
|
||||
@@ -60,7 +58,7 @@ describe 'nova::db::mysql' do
|
||||
{ :charset => 'latin1' }.merge(required_params)
|
||||
end
|
||||
|
||||
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
|
||||
it { should contain_openstacklib__db__mysql('nova').with_charset(params[:charset]) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,16 +73,6 @@ describe 'nova::db::mysql' do
|
||||
}
|
||||
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
|
||||
|
||||
describe "overriding allowed_hosts param to string" do
|
||||
@@ -98,11 +86,6 @@ describe 'nova::db::mysql' do
|
||||
}
|
||||
end
|
||||
|
||||
it {should contain_nova__db__mysql__host_access("192.168.1.1").with(
|
||||
:user => 'nova',
|
||||
:password => 'novapass2',
|
||||
:database => 'nova'
|
||||
)}
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param equals to host param " do
|
||||
@@ -116,10 +99,5 @@ describe 'nova::db::mysql' do
|
||||
}
|
||||
end
|
||||
|
||||
it {should_not contain_nova__db__mysql__host_access("127.0.0.1").with(
|
||||
:user => 'nova',
|
||||
:password => 'novapass2',
|
||||
:database => 'nova'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user