Refactor heat_db_sync

This commit is contained in:
Dmitry Ilyin 2013-10-11 19:18:51 +04:00 committed by Dmitry Ilyin
parent 68b085cfe2
commit e83322a8f9
4 changed files with 24 additions and 18 deletions

View File

@ -35,25 +35,25 @@ class heat::db (
'DEFAULT/sql_connection': value => $sql_connection; 'DEFAULT/sql_connection': value => $sql_connection;
} }
exec { 'db_sync' : file { 'db_sync_script' :
command => $db_sync_command, ensure => present,
path => '/usr/bin', path => $::heat::params::heat_db_sync_command,
user => 'heat', owner => 'root',
refreshonly => true, group => 'root',
logoutput => on_failure, mode => '0755',
onlyif => "test -f $db_sync_command", content => template('heat/heat_db_sync.sh.erb'),
subscribe => [Package['heat-engine'], Package['heat-api'],],
} }
# Lagacy part - support old rpms before 2013.2.xx without heat-manage tool exec { 'heat_db_sync' :
exec { 'legacy_db_sync' : command => $::heat::params::heat_db_sync_command,
command => $legacy_db_sync_command, path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin' ],
path => '/usr/bin',
user => 'heat', user => 'heat',
refreshonly => true, refreshonly => true,
logoutput => on_failure, logoutput => 'on_failure',
unless => "test -f $db_sync_command",
subscribe => [Package['heat-engine'], Package['heat-api'],],
} }
File['db_sync_script'] ~> Exec['heat_db_sync']
Package['heat-engine'] ~> Exec['heat_db_sync']
Package['heat-api'] ~> Exec['heat_db_sync']
} }

View File

@ -16,8 +16,6 @@ class heat::db::mysql(
grant => ['all'], grant => ['all'],
} }
Class['mysql::server'] -> Mysql::Db[$dbname] Class['mysql::server'] -> Mysql::Db[$dbname] ~> Exec['heat_db_sync']
Mysql::Db[$dbname] ~> Exec['db_sync']
Mysql::Db[$dbname] ~> Exec['legacy_db_sync']
} }

View File

@ -19,5 +19,6 @@ class heat::params {
$db_sync_command = '/usr/bin/heat-manage db_sync' $db_sync_command = '/usr/bin/heat-manage db_sync'
$legacy_db_sync_command = '/usr/bin/python -m heat.db.sync' $legacy_db_sync_command = '/usr/bin/python -m heat.db.sync'
$heat_db_sync_command = '/usr/local/bin/heat_db_sync'
} }

View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ -f "/usr/bin/heat-manage" ]; then
/usr/bin/heat-manage db_sync
else
/usr/bin/python -m heat.db.sync
fi