diff --git a/manifests/api.pp b/manifests/api.pp index de284095..d6f0f4b8 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -87,41 +87,41 @@ class gnocchi::api ( tag => ['openstack', 'gnocchi-package'], } + if $sync_db { + include gnocchi::db::sync + } + if $manage_service { if $enabled { $service_ensure = 'running' } else { $service_ensure = 'stopped' } - } - if $sync_db { - include gnocchi::db::sync - } + if $service_name == $::gnocchi::params::api_service_name { + service { 'gnocchi-api': + ensure => $service_ensure, + name => $::gnocchi::params::api_service_name, + enable => $enabled, + hasstatus => true, + hasrestart => true, + tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + } + } elsif $service_name == 'httpd' { + service { 'gnocchi-api': + ensure => 'stopped', + name => $::gnocchi::params::api_service_name, + enable => false, + tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + } + Service <| title == 'httpd' |> { tag +> 'gnocchi-service' } - if $service_name == $::gnocchi::params::api_service_name { - service { 'gnocchi-api': - ensure => $service_ensure, - name => $::gnocchi::params::api_service_name, - enable => $enabled, - hasstatus => true, - hasrestart => true, - tag => ['gnocchi-service', 'gnocchi-db-sync-service'], - } - } elsif $service_name == 'httpd' { - service { 'gnocchi-api': - ensure => 'stopped', - name => $::gnocchi::params::api_service_name, - enable => false, - tag => ['gnocchi-service', 'gnocchi-db-sync-service'], - } - Service <| title == 'httpd' |> { tag +> 'gnocchi-service' } - - # we need to make sure gnocchi-api/eventlet is stopped before trying to start apache - Service['gnocchi-api'] -> Service[$service_name] - } else { - fail("Invalid service_name. Either gnocchi/openstack-gnocchi-api for running as a \ + # we need to make sure gnocchi-api/eventlet is stopped before trying to start apache + Service['gnocchi-api'] -> Service[$service_name] + } else { + fail("Invalid service_name. Either gnocchi/openstack-gnocchi-api for running as a \ standalone service, or httpd for being run by a httpd server") + } } gnocchi_config { diff --git a/manifests/metricd.pp b/manifests/metricd.pp index ed9c45e1..c2081d8f 100644 --- a/manifests/metricd.pp +++ b/manifests/metricd.pp @@ -87,15 +87,14 @@ class gnocchi::metricd ( } else { $service_ensure = 'stopped' } - } - service { 'gnocchi-metricd': - ensure => $service_ensure, - name => $::gnocchi::params::metricd_service_name, - enable => $enabled, - hasstatus => true, - hasrestart => true, - tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + service { 'gnocchi-metricd': + ensure => $service_ensure, + name => $::gnocchi::params::metricd_service_name, + enable => $enabled, + hasstatus => true, + hasrestart => true, + tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + } } - } diff --git a/manifests/statsd.pp b/manifests/statsd.pp index e2c32336..4a5c6a0f 100644 --- a/manifests/statsd.pp +++ b/manifests/statsd.pp @@ -48,15 +48,15 @@ class gnocchi::statsd ( } else { $service_ensure = 'stopped' } - } - service { 'gnocchi-statsd': - ensure => $service_ensure, - name => $::gnocchi::params::statsd_service_name, - enable => $enabled, - hasstatus => true, - hasrestart => true, - tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + service { 'gnocchi-statsd': + ensure => $service_ensure, + name => $::gnocchi::params::statsd_service_name, + enable => $enabled, + hasstatus => true, + hasrestart => true, + tag => ['gnocchi-service', 'gnocchi-db-sync-service'], + } } gnocchi_config { diff --git a/spec/classes/gnocchi_api_spec.rb b/spec/classes/gnocchi_api_spec.rb index e590a110..7405cb2d 100644 --- a/spec/classes/gnocchi_api_spec.rb +++ b/spec/classes/gnocchi_api_spec.rb @@ -75,7 +75,7 @@ describe 'gnocchi::api' do it 'configures gnocchi-api service' do is_expected.to contain_service('gnocchi-api').with( - :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :ensure => params[:enabled] ? 'running' : 'stopped', :name => platform_params[:api_service_name], :enable => params[:enabled], :hasstatus => true, @@ -99,19 +99,12 @@ describe 'gnocchi::api' do context 'with disabled service managing' do before do params.merge!({ - :manage_service => false, - :enabled => false }) + :manage_service => false + }) end - it 'configures gnocchi-api service' do - is_expected.to contain_service('gnocchi-api').with( - :ensure => nil, - :name => platform_params[:api_service_name], - :enable => false, - :hasstatus => true, - :hasrestart => true, - :tag => ['gnocchi-service', 'gnocchi-db-sync-service'], - ) + it 'does not configure gnocchi-api service' do + is_expected.to_not contain_service('gnocchi-api') end end diff --git a/spec/classes/gnocchi_metricd_spec.rb b/spec/classes/gnocchi_metricd_spec.rb index 4dd9c91f..c9ed069c 100644 --- a/spec/classes/gnocchi_metricd_spec.rb +++ b/spec/classes/gnocchi_metricd_spec.rb @@ -49,19 +49,12 @@ describe 'gnocchi::metricd' do context 'with disabled service managing' do before do params.merge!({ - :manage_service => false, - :enabled => false }) + :manage_service => false + }) end - it 'configures gnocchi-metricd service' do - is_expected.to contain_service('gnocchi-metricd').with( - :ensure => nil, - :name => platform_params[:metricd_service_name], - :enable => false, - :hasstatus => true, - :hasrestart => true, - :tag => ['gnocchi-service', 'gnocchi-db-sync-service'], - ) + it 'does not configure gnocchi-metricd service' do + is_expected.to_not contain_service('gnocchi-metricd') end end diff --git a/spec/classes/gnocchi_statsd_spec.rb b/spec/classes/gnocchi_statsd_spec.rb index 016fd504..20a62c6c 100644 --- a/spec/classes/gnocchi_statsd_spec.rb +++ b/spec/classes/gnocchi_statsd_spec.rb @@ -37,7 +37,7 @@ describe 'gnocchi::statsd' do it 'configures gnocchi-statsd service' do is_expected.to contain_service('gnocchi-statsd').with( - :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :ensure => params[:enabled] ? 'running' : 'stopped', :name => platform_params[:statsd_service_name], :enable => params[:enabled], :hasstatus => true, @@ -51,19 +51,12 @@ describe 'gnocchi::statsd' do context 'with disabled service managing' do before do params.merge!({ - :manage_service => false, - :enabled => false }) + :manage_service => false + }) end - it 'configures gnocchi-statsd service' do - is_expected.to contain_service('gnocchi-statsd').with( - :ensure => nil, - :name => platform_params[:statsd_service_name], - :enable => false, - :hasstatus => true, - :hasrestart => true, - :tag => ['gnocchi-service', 'gnocchi-db-sync-service'], - ) + it 'does not configure gnocchi-statsd service' do + is_expected.to_not contain_service('gnocchi-statsd') end end