Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add service enable flag #27

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The following parameters are available in the `otelcol` class:
* [`metrics_address_host`](#-otelcol--metrics_address_host)
* [`metrics_address_port`](#-otelcol--metrics_address_port)
* [`service_ensure`](#-otelcol--service_ensure)
* [`service_enable`](#-otelcol--service_enable)
* [`manage_service`](#-otelcol--manage_service)
* [`manage_archive`](#-otelcol--manage_archive)
* [`localpath_archive`](#-otelcol--localpath_archive)
Expand Down Expand Up @@ -240,6 +241,14 @@ Ensure for service

Default value: `'running'`

##### <a name="-otelcol--service_enable"></a>`service_enable`

Data type: `Boolean`

Enable the service on boot

Default value: `true`

##### <a name="-otelcol--manage_service"></a>`manage_service`

Data type: `Boolean`
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
# Port metrics are listening to
# @param service_ensure
# Ensure for service
# @param service_enable
# Enable the service on boot
# @param manage_service
# If service is managed by module
# @param manage_archive
Expand Down Expand Up @@ -75,6 +77,7 @@
Optional[Stdlib::Host] $metrics_address_host = undef,
Stdlib::Port $metrics_address_port = 8888,
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $service_enable = true,
Boolean $manage_service = true,
Boolean $manage_archive = false,
String[1] $localpath_archive = '/tmp',
Expand Down
5 changes: 5 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
# @param ensure
# Ensure service status
#
# @param enable
# Enable service on boot
#
# @api private
class otelcol::service (
Stdlib::Ensure::Service $ensure = $otelcol::service_ensure,
Boolean $enable = $otelcol::service_enable,
String $config_check_command = "${otelcol::service_name} validate --config=${otelcol::config_file}",
Boolean $config_check = $otelcol::service_configcheck,
) {
Expand Down Expand Up @@ -42,6 +46,7 @@

service { 'otelcol':
ensure => $ensure,
enable => $enable,
name => $otelcol::service_name,
require => $service_require,
subscribe => [Concat['otelcol-config'], File['otelcol-environment']],
Expand Down
1 change: 1 addition & 0 deletions spec/classes/otelcol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
it {
is_expected.to contain_class('otelcol::service')
is_expected.to contain_service('otelcol').with_ensure('running').with_name('otelcol')
is_expected.to contain_service('otelcol').with_enable('true').with_name('otelcol')
}
end

Expand Down
Loading