Skip to content

Commit 0b25ffd

Browse files
authored
[ansible][windows] Add option to set service CLI args (#6371)
* [ansible][windows] Add support to custom cmd line * Fix lint * Remove `when` conditional from the assert * Remove conditional from custom_vars Windows test * Playbook option is not available on verify step * Remove accidental changes on Makefile
1 parent a8cfb38 commit 0b25ffd

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

deployments/ansible/molecule/custom_vars/windows-converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
MY_CUSTOM_VAR1: value1
2323
MY_CUSTOM_VAR2: value2
2424
MY_CUSTOM_VAR3: 'value3 with spaces'
25+
splunk_otel_collector_command_line_args: "--discovery"
2526
install_splunk_dotnet_auto_instrumentation: true
2627
splunk_dotnet_auto_instrumentation_version: 1.8.0
2728
splunk_dotnet_auto_instrumentation_system_wide: true

deployments/ansible/molecule/custom_vars/windows-verify.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,14 @@
9595
assert:
9696
that: (item.key + '=' + (item.value | string)) in collector_env.value
9797
loop: "{{ collector_reg_values | dict2items }}"
98+
99+
- name: Get splunk-otel-collector service ImagePath
100+
ansible.windows.win_reg_stat:
101+
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
102+
name: ImagePath
103+
register: collector_imagepath
104+
105+
- name: Assert service ImagePath ends with the splunk_otel_collector_command_line_args value used in the playbook
106+
assert:
107+
that:
108+
- collector_imagepath.value.endswith("--discovery")

deployments/ansible/roles/collector/tasks/otel_win_install.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
- "{{ 'SPLUNK_MEMORY_TOTAL_MIB=' + (splunk_memory_total_mib | string)
3232
if (splunk_memory_total_mib | string) != '' else '' }}"
3333
- "{{ 'SPLUNK_REALM=' + splunk_realm if splunk_realm != '' else '' }}"
34+
- "{{ 'COLLECTOR_SVC_ARGS=' + splunk_otel_collector_command_line_args
35+
if splunk_otel_collector_command_line_args != '' else '' }}"
3436

3537
- name: Filter out undefined arguments
3638
when: splunk_collector_msi_is_configurable is defined
@@ -95,4 +97,4 @@
9597
ansible.windows.win_template:
9698
src: "{{splunk_otel_collector_config_source}}"
9799
dest: "{{splunk_otel_collector_config}}"
98-
when: splunk_otel_collector_config_source != ""
100+
when: splunk_otel_collector_config_source != ''

0 commit comments

Comments
 (0)