Refactor api service management

Drop validation of service name which is not implemented for
the other daemons, to simplify handling of the provided service name.

This allows us to more easily offload the service name definition to
hiera data in the near future.

Change-Id: Id241996b862c8cc564ebbc2fb001fe13635ffc08
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-09-27 00:32:39 +09:00
parent 4852cd1d46
commit 30b8c09cec

View File

@@ -122,7 +122,7 @@
class octavia::api (
Boolean $enabled = true,
Boolean $manage_service = true,
$service_name = $octavia::params::api_service_name,
String[1] $service_name = $octavia::params::api_service_name,
$host = '0.0.0.0',
$port = '9876',
$package_ensure = 'present',
@@ -163,36 +163,36 @@ class octavia::api (
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
case $service_name {
'httpd': {
Service<| title == 'httpd' |> { tag +> 'octavia-service' }
if $service_name == $octavia::params::api_service_name {
service { 'octavia-api':
ensure => $service_ensure,
name => $octavia::params::api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'octavia-service',
service { 'octavia-api':
ensure => 'stopped',
name => $octavia::params::api_service_name,
enable => false,
tag => 'octavia-service',
}
Service['octavia-api'] -> Service[$service_name]
}
default: {
$service_ensure = $enabled ? {
true => 'running',
default => 'stopped',
}
# On any uwsgi config change, we must restart Octavia API.
Octavia_api_uwsgi_config<||> ~> Service['octavia-api']
} elsif $service_name == 'httpd' {
service { 'octavia-api':
ensure => 'stopped',
name => $octavia::params::api_service_name,
enable => false,
tag => 'octavia-service',
service { 'octavia-api':
ensure => $service_ensure,
name => $octavia::params::api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'octavia-service',
}
# On any uwsgi config change, we must restart Octavia API.
Octavia_api_uwsgi_config<||> ~> Service['octavia-api']
}
Service['octavia-api'] -> Service[$service_name]
Service<| title == 'httpd' |> { tag +> 'octavia-service' }
} else {
fail("Invalid service_name. Either octavia-api/openstack-octavia-api for \
running as a standalone service, or httpd for being run by a httpd server")
}
}