From 56af7256aec75057c8ae03c5ad52c4721a57c294 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Mon, 4 May 2020 13:40:00 +0200 Subject: [PATCH] Allow using cloudkitty-api as service name In Debian, cloudkitty-api is running over UWSGI, which is a fine way to run APIs. This patch makes it possible to use that, instead of Apache. Change-Id: I1cdd9bec4b23a3a0e65fe3eb4ceb79943330e2d4 --- manifests/api.pp | 10 +++++++++- .../notes/debian-uwsgi-7e64888abb29273a.yaml | 6 ++++++ spec/classes/cloudkitty_api_spec.rb | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/debian-uwsgi-7e64888abb29273a.yaml diff --git a/manifests/api.pp b/manifests/api.pp index e1ef016..86f0ecf 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -74,7 +74,15 @@ class cloudkitty::api ( include cloudkitty::db::sync } - if $service_name == 'httpd' { + if $service_name == $::cloudkitty::params::api_service_name { + service { 'cloudkitty-api': + enable => $enabled, + name => 'cloudkitty-api', + hasstatus => true, + hasrestart => true, + tag => 'cloudkitty-service', + } + } elsif $service_name == 'httpd' { include apache::params service { 'cloudkitty-api': ensure => 'stopped', diff --git a/releasenotes/notes/debian-uwsgi-7e64888abb29273a.yaml b/releasenotes/notes/debian-uwsgi-7e64888abb29273a.yaml new file mode 100644 index 0000000..bf158aa --- /dev/null +++ b/releasenotes/notes/debian-uwsgi-7e64888abb29273a.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + It is now possible to run cloudkitty-api using the default package service, + which may be useful if running under Debian, where cloudkitty-api runs + using uwsgi. diff --git a/spec/classes/cloudkitty_api_spec.rb b/spec/classes/cloudkitty_api_spec.rb index 759e0e7..4d8481a 100644 --- a/spec/classes/cloudkitty_api_spec.rb +++ b/spec/classes/cloudkitty_api_spec.rb @@ -54,6 +54,22 @@ describe 'cloudkitty::api' do end end + context 'when running cloudkitty-api as standalone' do + before do + params.merge!({ :service_name => platform_params[:api_service_name] }) + end + + it 'configures cloudkitty-api service as standalone' do + is_expected.to contain_service('cloudkitty-api').with( + :enable => true, + :name => platform_params[:api_service_name], + :hasstatus => true, + :hasrestart => true, + :tag => 'cloudkitty-service', + ) + end + end + context 'when service_name is not valid' do before do params.merge!({ :service_name => 'foobar' })