Skip to content

Commit c05b29b

Browse files
authored
[chef]Add option to set service CLI args (#6290)
1 parent 57cc873 commit c05b29b

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

deployments/chef/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ required `splunk_access_token` attribute and some optional attributes:
148148
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector`
149149
registry key.
150150

151+
- `collector_command_line_args`: Additional command line arguments to pass to the
152+
collector service. The value will be set to the `OTELCOL_OPTIONS` environment
153+
variable for the collector service (**default:** `''`).
154+
151155
### Fluentd
152156

153157
- `with_fluentd`: Whether to install/manage Fluentd and dependencies for log

deployments/chef/attributes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'4.3.2'
3232
end
3333
default['splunk_otel_collector']['collector_additional_env_vars'] = {}
34+
default['splunk_otel_collector']['collector_command_line_args'] = ''
3435

3536
if platform_family?('windows')
3637
default['splunk_otel_collector']['collector_version'] = 'latest'

deployments/chef/kitchen.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ suites:
9292
collector_additional_env_vars:
9393
MY_CUSTOM_VAR1: value1
9494
MY_CUSTOM_VAR2: value2
95+
collector_command_line_args: --discovery
9596
with_fluentd: true
9697

9798
- name: with_default_preload_instrumentation

deployments/chef/templates/splunk-otel-collector.conf.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ SPLUNK_BUNDLE_DIR=<%= node['splunk_otel_collector']['splunk_bundle_dir'] %>
3939
# This directory must be read/writable by the collector process.
4040
SPLUNK_COLLECTD_DIR=<%= node['splunk_otel_collector']['splunk_collectd_dir'] %>
4141

42+
<% unless node['splunk_otel_collector']['collector_command_line_args'].to_s.strip.empty? -%>
43+
# Additional command line arguments for the collector.
44+
OTELCOL_OPTIONS=<%= node['splunk_otel_collector']['collector_command_line_args'] %>
45+
<% end -%>
46+
4247
# Additional environment variables.
4348
<% @node['splunk_otel_collector']['collector_additional_env_vars'].each do |key,value| -%>
4449
<%= key %>=<%= value %>

deployments/chef/test/integration/custom_vars/test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
its('content') { should match /^SPLUNK_REALM=test$/ }
6666
its('content') { should match /^MY_CUSTOM_VAR1=value1$/ }
6767
its('content') { should match /^MY_CUSTOM_VAR2=value2$/ }
68+
its('content') { should match /^OTELCOL_OPTIONS=--discovery$/ }
6869
end
6970
describe file('/etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf') do
7071
its('content') { should match /^User=custom-user$/ }

0 commit comments

Comments
 (0)