Skip to content

Commit

Permalink
add service enable flag (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberkov authored Jan 10, 2025
1 parent 190436a commit 5c6b338
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
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

0 comments on commit 5c6b338

Please sign in to comment.