diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 4eb0fc58..5965f196 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -1,18 +1,36 @@ # class cinder::db::mysql ( $password, - $dbname = 'cinder', - $user = 'cinder', + $dbname = 'cinder', + $user = 'cinder', + $host = '127.0.0.1', + $allowed_hosts = undef, + $charset = 'latin1', + $cluster_id = 'localzone' ) { include cinder::params + Class['mysql::server'] -> Class['cinder::db::mysql'] Class['cinder::db::mysql'] -> Class['cinder::db::sync'] Database[$dbname] ~> Exec<| title == 'cinder-manage db_sync' |> mysql::db { $dbname: - host => '127.0.0.1', - user => $user, - password => $password, + user => $user, + password => $password, + host => $host, + charset => $charset, + # I may want to inject some sql + require => Class['mysql::config'], } + + if $allowed_hosts { + # TODO this class should be in the mysql namespace + cinder::db::mysql::host_access { $allowed_hosts: + user => $user, + password => $password, + database => $dbname, + } + } + } diff --git a/manifests/db/mysql/host_access.pp b/manifests/db/mysql/host_access.pp new file mode 100644 index 00000000..8cca4287 --- /dev/null +++ b/manifests/db/mysql/host_access.pp @@ -0,0 +1,16 @@ +# +# Used to grant access to the cinder mysql DB +# +define cinder::db::mysql::host_access ($user, $password, $database) { + 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}"] + } +} diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 53d62753..942f2521 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -9,5 +9,6 @@ class cinder::db::sync { user => 'cinder', refreshonly => true, require => [File[$::cinder::params::cinder_conf], Class['cinder']], + logoutput => 'on_failure', } } diff --git a/manifests/init.pp b/manifests/init.pp index 0fb5c575..b5a05541 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,6 +29,13 @@ class cinder ( file { $::cinder::params::cinder_conf: } file { $::cinder::params::cinder_paste_api_ini: } + # Temporary fixes + file { ['/var/log/cinder', '/var/lib/cinder']: + ensure => directory, + owner => 'cinder', + group => 'adm', + } + if $cinder_settings { multini($::cinder::params::cinder_conf, $cinder_settings) }