Creation of ceilometer::db::sync
In order to standardize the way dbsync are run across our modules, we create a new class ceilometer::db::sync. This class will be included if sync_db is enabled. By making this transition the ceilometer::db::sync can be returned by the ENC. A use case would be in an highly available environment, with 3 galera nodes, include ceilometer::db on every node with sync_db set to false and have the ENC return ceilometer::db::sync just for one node. Change-Id: I410f41fb4e61be848372820cdeb2110efc327161
This commit is contained in:
parent
fe4eb1f5ef
commit
7b920066e1
|
@ -115,6 +115,7 @@ class ceilometer::api (
|
||||||
$service_ensure = 'stopped'
|
$service_ensure = 'stopped'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['ceilometer-common'] -> Service[$service_name]
|
Package['ceilometer-common'] -> Service[$service_name]
|
||||||
|
|
||||||
if $service_name == $::ceilometer::params::api_service_name {
|
if $service_name == $::ceilometer::params::api_service_name {
|
||||||
|
|
|
@ -53,8 +53,6 @@ class ceilometer::collector (
|
||||||
if $manage_service {
|
if $manage_service {
|
||||||
if $enabled {
|
if $enabled {
|
||||||
$service_ensure = 'running'
|
$service_ensure = 'running'
|
||||||
Class['ceilometer::db'] -> Service['ceilometer-collector']
|
|
||||||
Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector']
|
|
||||||
} else {
|
} else {
|
||||||
$service_ensure = 'stopped'
|
$service_ensure = 'stopped'
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,6 @@ class ceilometer::db (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if $sync_db {
|
|
||||||
$command = $::ceilometer::params::dbsync_command
|
|
||||||
} else {
|
|
||||||
$command = '/bin/true'
|
|
||||||
}
|
|
||||||
|
|
||||||
if $backend_package and !defined(Package[$backend_package]) {
|
if $backend_package and !defined(Package[$backend_package]) {
|
||||||
package {'ceilometer-backend-package':
|
package {'ceilometer-backend-package':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
|
@ -68,15 +62,8 @@ class ceilometer::db (
|
||||||
'database/connection': value => $database_connection, secret => true;
|
'database/connection': value => $database_connection, secret => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ceilometer_config['database/connection'] ~> Exec['ceilometer-dbsync']
|
if $sync_db {
|
||||||
|
include ::ceilometer::db::sync
|
||||||
exec { 'ceilometer-dbsync':
|
|
||||||
command => $command,
|
|
||||||
path => '/usr/bin',
|
|
||||||
user => $::ceilometer::params::user,
|
|
||||||
refreshonly => true,
|
|
||||||
logoutput => on_failure,
|
|
||||||
subscribe => Ceilometer_config['database/connection']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# Class to execute ceilometer dbsync
|
||||||
|
#
|
||||||
|
class ceilometer::db::sync {
|
||||||
|
|
||||||
|
include ::ceilometer::params
|
||||||
|
|
||||||
|
Package<| tag == 'ceilometer-package' |> ~> Exec['ceilometer-dbsync']
|
||||||
|
Exec['ceilometer-dbsync'] ~> Service <| tag == 'ceilometer-service' |>
|
||||||
|
|
||||||
|
Ceilometer_config<||> -> Exec['ceilometer-dbsync']
|
||||||
|
Ceilometer_config<| title == 'database/connection' |> ~> Exec['ceilometer-dbsync']
|
||||||
|
|
||||||
|
exec { 'ceilometer-dbsync':
|
||||||
|
command => $::ceilometer::params::dbsync_command,
|
||||||
|
path => '/usr/bin',
|
||||||
|
user => $::ceilometer::params::user,
|
||||||
|
refreshonly => true,
|
||||||
|
logoutput => on_failure,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -91,7 +91,6 @@ describe 'ceilometer::api' do
|
||||||
:hasstatus => true,
|
:hasstatus => true,
|
||||||
:hasrestart => true,
|
:hasrestart => true,
|
||||||
:require => 'Class[Ceilometer::Db]',
|
:require => 'Class[Ceilometer::Db]',
|
||||||
:subscribe => 'Exec[ceilometer-dbsync]',
|
|
||||||
:tag => 'ceilometer-service',
|
:tag => 'ceilometer-service',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,10 +69,6 @@ describe 'ceilometer::collector' do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures relationships on database' do
|
|
||||||
is_expected.to contain_class('ceilometer::db').with_before(['Service[ceilometer-collector]'])
|
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with_notify(['Service[ceilometer-collector]'])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when disabled' do
|
context 'when disabled' do
|
||||||
|
|
|
@ -25,14 +25,8 @@ describe 'ceilometer::db' do
|
||||||
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'runs ceilometer-dbsync' do
|
it 'includes ceilometer::db::sync' do
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with(
|
is_expected.to contain_class('ceilometer::db::sync')
|
||||||
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
|
|
||||||
:path => '/usr/bin',
|
|
||||||
:refreshonly => 'true',
|
|
||||||
:user => 'ceilometer',
|
|
||||||
:logoutput => 'on_failure'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,14 +53,8 @@ describe 'ceilometer::db' do
|
||||||
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'runs ceilometer-dbsync' do
|
it 'does not include ceilometer::db::sync' do
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with(
|
is_expected.not_to contain_class('ceilometer::db::sync')
|
||||||
:command => '/bin/true',
|
|
||||||
:path => '/usr/bin',
|
|
||||||
:refreshonly => 'true',
|
|
||||||
:user => 'ceilometer',
|
|
||||||
:logoutput => 'on_failure'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,14 +80,8 @@ describe 'ceilometer::db' do
|
||||||
:name => 'python-pymongo')
|
:name => 'python-pymongo')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'runs ceilometer-dbsync' do
|
it 'includes ceilometer::db::sync' do
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with(
|
is_expected.to contain_class('ceilometer::db::sync')
|
||||||
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
|
|
||||||
:path => '/usr/bin',
|
|
||||||
:refreshonly => 'true',
|
|
||||||
:user => 'ceilometer',
|
|
||||||
:logoutput => 'on_failure'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,14 +106,8 @@ describe 'ceilometer::db' do
|
||||||
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'runs ceilometer-dbsync' do
|
it 'does not include ceilomter::db::sync' do
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with(
|
is_expected.not_to contain_class('ceilometer::db::sync')
|
||||||
:command => '/bin/true',
|
|
||||||
:path => '/usr/bin',
|
|
||||||
:refreshonly => 'true',
|
|
||||||
:user => 'ceilometer',
|
|
||||||
:logoutput => 'on_failure'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -154,14 +130,8 @@ describe 'ceilometer::db' do
|
||||||
:name => 'python-pysqlite2')
|
:name => 'python-pysqlite2')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'runs ceilometer-dbsync' do
|
it 'includes ceilometer::db::sync' do
|
||||||
is_expected.to contain_exec('ceilometer-dbsync').with(
|
is_expected.to contain_class('ceilometer::db::sync')
|
||||||
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
|
|
||||||
:path => '/usr/bin',
|
|
||||||
:refreshonly => 'true',
|
|
||||||
:user => 'ceilometer',
|
|
||||||
:logoutput => 'on_failure'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'ceilometer::db::sync' do
|
||||||
|
|
||||||
|
shared_examples_for 'ceilometer-dbsync' do
|
||||||
|
|
||||||
|
it 'runs ceilometer-dbsync' do
|
||||||
|
is_expected.to contain_exec('ceilometer-dbsync').with(
|
||||||
|
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
|
||||||
|
:path => '/usr/bin',
|
||||||
|
:refreshonly => 'true',
|
||||||
|
:user => 'ceilometer',
|
||||||
|
:logoutput => 'on_failure'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a RedHat osfamily' do
|
||||||
|
let :facts do
|
||||||
|
{
|
||||||
|
:osfamily => 'RedHat',
|
||||||
|
:operatingsystemrelease => '7.0',
|
||||||
|
:concat_basedir => '/var/lib/puppet/concat'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'ceilometer-dbsync'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on a Debian osfamily' do
|
||||||
|
let :facts do
|
||||||
|
{
|
||||||
|
:operatingsystemrelease => '7.8',
|
||||||
|
:operatingsystem => 'Debian',
|
||||||
|
:osfamily => 'Debian',
|
||||||
|
:concat_basedir => '/var/lib/puppet/concat'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'ceilometer-dbsync'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue