Skip to content

Commit e82f3ef

Browse files
crobert-1pjanotti
andauthored
[ansible] Upgrade version tested for Windows (#6288)
* [chore][ansible] Upgrade version tested for Windows * fix ansible lint * touch log file * change log_path to be a host path (rather than windows) * debug: upload msi install logs to github artifact ouput * Don't stop ansible deploy on failure, collector log file * change path used for win install log file * use absolute path without substitutes * use unique name for log files from windows ansible msi install * fail job if molecule test fails, but still upload logs * Change to show step failure, but still execute uploading of logs * Always fetch logs as github workflow determines whether to upload them * Only upload log files if molecule tests failed * Upload logs even if successful molecule test * ignoring errors, upload all matching files, not directory * attempt to add timeout to msi install * save async results file, give github artifacts unique names * fix upload naming to include ansible version, add more log debugging * add win registry variable output * use regex replace for surrounding MSI arg values with spaces * all tests failed with escaped double-quotes, test un-escaped * no escaping failed lint, try two backslashes for escaping * separate out regex and replacement strings into vars * double escape didn't work, the group specifiers were broken. attempt no escaping again * only use one backslash for group replacement regex * Existing code was working for parsing, but still failing msi install. Try leading space * Move back to no leading space, extend timeout * use backticks around double quotes * Join msi argument list into space separated string, remove whoami output * properly get variable value for join * add debugging to check env vars set on windows ansible * debugging: attempt to only do regex when arg contains spaces * split when into list of and conditions * make two lists of args, differentiated by spaces. Only add quotes to space args * remove backticks in regex replace, remove async behavior * splunk_config_override and splunk_otel_collector_config_* arguments are still valid * use set additional vars in msi package install args * Only add additional env vars when they're defined * Fix variable reference to correct one * Set win reg keys for custom variables * remove empty lines at beginning of file * debug: get existing contents of windows registry * append existing win reg with custom vars * fix linting of line too long * add proper when qualifiers to otel_win_reg * Make win reg entry unique for the sake of idempotence, use not-deprecated config in test * Remove debugging and fix typos and formatting * test if MSI arguments must be space separated string, or if array works * Fix when check to resolve error saying variable doesn't have properties * Join msi arguments is required for values with spaces * add changelog for ansible fixing bugs * Update deployments/ansible/CHANGELOG.md Co-authored-by: Paulo Janotti <[email protected]> * Update deployments/ansible/CHANGELOG.md Co-authored-by: Paulo Janotti <[email protected]> --------- Co-authored-by: Paulo Janotti <[email protected]>
1 parent 0f83433 commit e82f3ef

File tree

6 files changed

+76
-20
lines changed

6 files changed

+76
-20
lines changed

deployments/ansible/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
configure the command line arguments for the Splunk OpenTelemetry Collector
99
service.
1010

11+
### 🧰 Bug fixes 🧰
12+
13+
- Fix bug causing Windows deployment failure when specified variables had spaces in their values (relevant when `splunk_otel_collector_version` >= `0.98.0`). ([#6288](https://github.com/signalfx/splunk-otel-collector/pull/6288))
14+
- Fix bug causing custom variables to not be set on Windows deployment (relevant when `splunk_otel_collector_version` >= `0.98.0`). ([#6288](https://github.com/signalfx/splunk-otel-collector/pull/6288))
15+
1116
## ansible-v0.31.0
1217

1318
### 🛑 Breaking changes 🛑

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
splunk_api_url: https://fake-splunk-api.com
99
splunk_hec_url: https://fake-splunk-hec.com
1010
splunk_hec_token: fake-hec-token
11-
splunk_otel_collector_version: 0.48.0
11+
splunk_otel_collector_version: 0.126.0
1212
splunk_otel_collector_config: '{{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\custom_config.yml'
13-
splunk_otel_collector_config_source: ./custom_collector_config_deprecated.yml
13+
splunk_otel_collector_config_source: ./custom_collector_config.yml
1414
splunk_memory_total_mib: 256
1515
gomemlimit: 230
1616
install_fluentd: yes

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@
4545
assert:
4646
that: not service_status.changed
4747

48-
- name: Download splunk-otel-collector 0.48.0 MSI
48+
- name: Download splunk-otel-collector 0.126.0 MSI
4949
ansible.windows.win_get_url:
50-
url: https://dl.signalfx.com/splunk-otel-collector/msi/release/splunk-otel-collector-0.48.0-amd64.msi
50+
url: https://dl.signalfx.com/splunk-otel-collector/msi/release/splunk-otel-collector-0.126.0-amd64.msi
5151
dest: "{{ansible_env.TEMP}}"
5252
register: otel_msi_package
5353

54-
- name: Install splunk-otel-collector 0.48.0 MSI
54+
- name: Install splunk-otel-collector 0.126.0 MSI
5555
ansible.windows.win_package:
5656
path: "{{otel_msi_package.dest}}"
5757
state: present
5858
check_mode: yes
5959
register: msi_installed
6060

61-
- name: Assert splunk-otel-collector 0.48.0 MSI is already installed
61+
- name: Assert splunk-otel-collector 0.126.0 MSI is already installed
6262
assert:
6363
that: not msi_installed.changed
6464

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,41 @@
6161
set_fact:
6262
msi_arguments: "{{ msi_unfiltered_arguments | reject('eq', '') | list }}"
6363

64+
- set_fact:
65+
args_without_spaces: []
66+
args_with_spaces: []
67+
68+
- name: Surround msi argument values with quotes to properly handle spaces in values
69+
when:
70+
- splunk_collector_msi_is_configurable is defined
71+
- item is search(' ')
72+
set_fact:
73+
args_with_spaces: "{{ args_with_spaces + [item | ansible.builtin.regex_replace(_regex, _replacement)] }}"
74+
vars:
75+
_regex: '^(.*)=(.*)$'
76+
_replacement: '\1="\2"'
77+
loop: "{{ msi_arguments }}"
78+
79+
- name: compile args without spaces
80+
set_fact:
81+
args_without_spaces: "{{ args_without_spaces + [item] }}"
82+
loop: "{{ msi_arguments }}"
83+
when:
84+
- splunk_collector_msi_is_configurable is defined
85+
- item is not search(' ')
86+
87+
- set_fact:
88+
msi_arguments: "{{ args_with_spaces + args_without_spaces }}"
89+
90+
- name: Join msi argument list into space separated string
91+
when: splunk_collector_msi_is_configurable is defined
92+
set_fact:
93+
msi_arguments: "{{ msi_arguments | join(' ') }}"
94+
6495
- name: Install splunk-otel-collector-msi
6596
when: splunk_collector_msi_is_configurable is defined
6697
ansible.windows.win_package:
67-
path: "{{otel_msi_package.dest}}"
98+
path: "{{ otel_msi_package.dest }}"
6899
state: present
69100
arguments: "{{ msi_arguments }}"
70101

@@ -76,22 +107,16 @@
76107

77108
- name: Merge custom config into the default config
78109
ansible.builtin.import_tasks: config_override.yml
79-
when:
80-
- splunk_collector_msi_is_configurable is undefined
81-
- splunk_config_override != ''
110+
when: splunk_config_override != ''
82111

83112
- name: Copy the custom config
84113
ansible.windows.win_copy:
85114
content: '{{ updated_config | to_nice_yaml (indent=2) }}'
86115
dest: "{{ splunk_otel_collector_config }}"
87-
when:
88-
- splunk_collector_msi_is_configurable is undefined
89-
- splunk_config_override != ''
116+
when: splunk_config_override != ''
90117

91118
- name: Push Custom Config file for splunk-otel-collector, If provided
92119
ansible.windows.win_template:
93120
src: "{{splunk_otel_collector_config_source}}"
94121
dest: "{{splunk_otel_collector_config}}"
95-
when:
96-
- splunk_collector_msi_is_configurable is undefined
97-
- splunk_otel_collector_config_source != ""
122+
when: splunk_otel_collector_config_source != ""
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
11
---
2-
- name: Get Splunk OpenTelemetry Collector options list
2+
- name: Get Splunk OpenTelemetry Collector options list (including default options)
3+
when: splunk_collector_msi_is_configurable is not defined
34
set_fact:
45
splunk_otel_collector_options_list: |-
56
{%- set value = item.value -%}
67
{{ (splunk_otel_collector_options_list | default([])) + [item.key + '=' + (value | string)] }}
78
loop: >
89
{{ splunk_otel_collector_options | default({}) | combine(splunk_otel_collector_additional_env_vars) | dict2items }}
910
11+
- name: Get Splunk OpenTelemetry Collector options list (only custom config variables)
12+
when: splunk_collector_msi_is_configurable is defined
13+
set_fact:
14+
splunk_otel_collector_options_list: |-
15+
{%- set value = item.value -%}
16+
{{ (splunk_otel_collector_options_list | default([])) + [item.key + '=' + (value | string)] }}
17+
loop: >
18+
{{ splunk_otel_collector_additional_env_vars | dict2items }}
19+
20+
- name: Get existing registry contents
21+
when:
22+
- splunk_collector_msi_is_configurable is defined
23+
- splunk_otel_collector_options_list is defined
24+
ansible.windows.win_reg_stat:
25+
path: "{{ splunk_otel_collector_service_registry_key }}"
26+
register: registry_contents
27+
28+
- name: Append custom variables to existing registry contents
29+
when:
30+
- splunk_collector_msi_is_configurable is defined
31+
- splunk_otel_collector_options_list is defined
32+
set_fact:
33+
splunk_otel_collector_options_list:
34+
"{{ registry_contents.properties.Environment.value + splunk_otel_collector_options_list }}"
35+
1036
- name: Set Splunk OpenTelemetry Collector registry value
37+
when:
38+
- splunk_otel_collector_options_list is defined
1139
ansible.windows.win_regedit:
1240
path: "{{ splunk_otel_collector_service_registry_key }}"
1341
state: present
1442
name: Environment
15-
data: "{{ splunk_otel_collector_options_list | sort }}"
43+
data: "{{ splunk_otel_collector_options_list | sort | unique }}"
1644
type: multistring
1745
notify: "restart windows splunk-otel-collector"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
2-
32
- name: Install Splunk OpenTelemetry Collector with msi package manager
43
ansible.builtin.import_tasks: otel_win_install.yml
54

65
- name: Set Windows Registry values
76
ansible.builtin.import_tasks: otel_win_reg.yml
8-
when: splunk_collector_msi_is_configurable is undefined
97

108
- name: Install Fluentd with msi package manager
119
ansible.builtin.import_tasks: win_fluentd_install.yml

0 commit comments

Comments
 (0)