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;
}
exec { 'db_sync' :
command => $db_sync_command,
path => '/usr/bin',
user => 'heat',
refreshonly => true,
logoutput => on_failure,
onlyif => "test -f $db_sync_command",
subscribe => [Package['heat-engine'], Package['heat-api'],],
file { 'db_sync_script' :
ensure => present,
path => $::heat::params::heat_db_sync_command,
owner => 'root',
group => 'root',
mode => '0755',
content => template('heat/heat_db_sync.sh.erb'),
}
# Lagacy part - support old rpms before 2013.2.xx without heat-manage tool
exec { 'legacy_db_sync' :
command => $legacy_db_sync_command,
path => '/usr/bin',
exec { 'heat_db_sync' :
command => $::heat::params::heat_db_sync_command,
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin' ],
user => 'heat',
refreshonly => true,
logoutput => on_failure,
unless => "test -f $db_sync_command",
subscribe => [Package['heat-engine'], Package['heat-api'],],
logoutput => 'on_failure',
}
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'],
}
Class['mysql::server'] -> Mysql::Db[$dbname]
Mysql::Db[$dbname] ~> Exec['db_sync']
Mysql::Db[$dbname] ~> Exec['legacy_db_sync']
Class['mysql::server'] -> Mysql::Db[$dbname] ~> Exec['heat_db_sync']
}

View File

@ -19,5 +19,6 @@ class heat::params {
$db_sync_command = '/usr/bin/heat-manage 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