Add manage_service parameter

... so that users can disable service management by Puppet. The same
functionality is already implemented in the other modules.

Change-Id: If08149ebd7b40b106327d5363f6b28e51176510e
This commit is contained in:
Takashi Kajinami 2022-09-02 00:57:01 +09:00
parent 4761d637b0
commit 449150fd05
5 changed files with 104 additions and 72 deletions

View File

@ -23,6 +23,10 @@
# (optional) Control the ensure parameter for the package resource.
# Defaults to 'present'.
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*enabled*]
# (optional) Define if the service must be enabled or not.
# Defaults to true.
@ -71,6 +75,7 @@
#
class ironic::api (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$service_name = $::ironic::params::api_service,
$host_ip = '0.0.0.0',
@ -105,36 +110,38 @@ class ironic::api (
}
}
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
if $service_name == $::ironic::params::api_service {
service { 'ironic-api':
ensure => $ensure,
name => $::ironic::params::api_service,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'ironic-service',
if $manage_service {
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
Keystone_endpoint<||> -> Service['ironic-api']
} elsif $service_name == 'httpd' {
service { 'ironic-api':
ensure => 'stopped',
name => $::ironic::params::api_service,
enable => false,
tag => 'ironic-service',
}
Service <| title == 'httpd' |> { tag +> 'ironic-service' }
# we need to make sure ironic-api/eventlet is stopped before trying to start apache
Service['ironic-api'] -> Service[$service_name]
} else {
fail("Invalid service_name. Either ironic-api/openstack-ironic-api for running as a \
if $service_name == $::ironic::params::api_service {
service { 'ironic-api':
ensure => $ensure,
name => $::ironic::params::api_service,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'ironic-service',
}
Keystone_endpoint<||> -> Service['ironic-api']
} elsif $service_name == 'httpd' {
service { 'ironic-api':
ensure => 'stopped',
name => $::ironic::params::api_service,
enable => false,
tag => 'ironic-service',
}
Service <| title == 'httpd' |> { tag +> 'ironic-service' }
# we need to make sure ironic-api/eventlet is stopped before trying to start apache
Service['ironic-api'] -> Service[$service_name]
} else {
fail("Invalid service_name. Either ironic-api/openstack-ironic-api for running as a \
standalone service, or httpd for being run by a httpd server")
}
}
oslo::middleware { 'ironic_config':

View File

@ -27,6 +27,10 @@
# (optional) Define if the service must be enabled or not.
# Defaults to true.
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*enabled_hardware_types*]
# (optional) Array of hardware types to load during service initialization.
# Defaults to $::os_service_default
@ -236,6 +240,7 @@
class ironic::conductor (
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$enabled_hardware_types = $::os_service_default,
$force_power_state_during_sync = true,
$http_url = $::os_service_default,
@ -417,19 +422,20 @@ class ironic::conductor (
}
}
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
if $manage_service {
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
# Manage service
service { 'ironic-conductor':
ensure => $ensure,
name => $::ironic::params::conductor_service,
enable => $enabled,
hasstatus => true,
tag => 'ironic-service',
# Manage service
service { 'ironic-conductor':
ensure => $ensure,
name => $::ironic::params::conductor_service,
enable => $enabled,
hasstatus => true,
tag => 'ironic-service',
}
}
}

View File

@ -21,6 +21,10 @@
# (optional) Control the ensure parameter for the package resource
# Defaults to 'present'
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*enabled*]
# (optional) Define if the service must be enabled or not
# Defaults to true
@ -196,6 +200,7 @@
#
class ironic::inspector (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$listen_address = $::os_service_default,
$pxe_transfer_protocol = 'tftp',
@ -355,33 +360,35 @@ class ironic::inspector (
include ironic::inspector::db::sync
}
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
if $manage_service {
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
# Manage services
service { 'ironic-inspector':
ensure => $ensure,
name => $::ironic::params::inspector_service,
enable => $enabled,
hasstatus => true,
tag => 'ironic-inspector-service',
}
Keystone_endpoint<||> -> Service['ironic-inspector']
if $::ironic::params::inspector_dnsmasq_service {
service { 'ironic-inspector-dnsmasq':
# Manage services
service { 'ironic-inspector':
ensure => $ensure,
name => $::ironic::params::inspector_dnsmasq_service,
name => $::ironic::params::inspector_service,
enable => $enabled,
hasstatus => true,
tag => 'ironic-inspector-dnsmasq-service',
subscribe => File['/etc/ironic-inspector/dnsmasq.conf'],
tag => 'ironic-inspector-service',
}
Keystone_endpoint<||> -> Service['ironic-inspector']
if $::ironic::params::inspector_dnsmasq_service {
service { 'ironic-inspector-dnsmasq':
ensure => $ensure,
name => $::ironic::params::inspector_dnsmasq_service,
enable => $enabled,
hasstatus => true,
tag => 'ironic-inspector-dnsmasq-service',
subscribe => File['/etc/ironic-inspector/dnsmasq.conf'],
}
} else {
warning("The ironic-inspector-dnsmasq service is not available. \
Please set up the dnsmasq service additionally.")
}
} else {
warning('The ironic-inspector-dnsmasq service is not available. \
Please set up the dnsmasq service additionally.')
}
}

View File

@ -21,6 +21,10 @@
# (optional) Control the ensure parameter for the package resource
# Defaults to 'present'
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*tftp_root*]
# (optional) Folder location to deploy PXE boot files
# Defaults to '/tftpboot'
@ -81,6 +85,7 @@
#
class ironic::pxe (
$package_ensure = 'present',
$manage_service = true,
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$http_port = 8088,
@ -204,16 +209,18 @@ class ironic::pxe (
content => template('ironic/dnsmasq_tftp_server.erb'),
}
service { 'dnsmasq-tftp-server':
ensure => 'running',
name => $::ironic::params::dnsmasq_tftp_service,
enable => true,
hasstatus => true,
subscribe => File['/etc/ironic/dnsmasq-tftp-server.conf'],
}
if $manage_service {
service { 'dnsmasq-tftp-server':
ensure => 'running',
name => $::ironic::params::dnsmasq_tftp_service,
enable => true,
hasstatus => true,
subscribe => File['/etc/ironic/dnsmasq-tftp-server.conf'],
}
Package['dnsmasq-tftp-server'] ~> Service['dnsmasq-tftp-server']
File[$tftp_root_real] -> Service['dnsmasq-tftp-server']
Package['dnsmasq-tftp-server'] ~> Service['dnsmasq-tftp-server']
File[$tftp_root_real] -> Service['dnsmasq-tftp-server']
}
}
# NOTE(tkajinam): Ubuntu/Debian requires a separate package for pxelinux.0

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``manage_service`` parameter has been added. This parameter
controls whether the service should be managed by Puppet.