Skip to content

Commit ae23889

Browse files
authored
[chore][ansible] Run Windows tests against current build (#6309)
* [chore][ansible] Use locally built artifact for Windows testing * set `needs` for windows testing * add task helper * Use job env rather than single entry matrix * fix windows var reference * upload file with expected name * download all artifacts * View all contents of /tmp * use win_copy instead of builtin copy * download all artifacts * block all ansible tests on lint * block another job on lint * don't care about collector ver if testing local artifact * debugging paths and file names * use ansible find for filename in controller * fix failed_when syntax * use win_find on target machine to get filename of MSI * fix ansible lint: double quotes around temp and string * fix escaped backslashes in double quotes * more stat, use task for creating temp dir * fix ansible lint: indent debug variable * properly expand variable * fix path finding * fix variable expansion * move to win_file instead of wintemp for idempotency * two backslashes inside of double quotes * move local install to its own yml, use reusable temp path fact * Remove debugging, as well as version-specific check * newlines at end of files
1 parent c006b31 commit ae23889

File tree

8 files changed

+196
-53
lines changed

8 files changed

+196
-53
lines changed

.github/workflows/ansible.yml

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ env:
3434
jobs:
3535
setup-environment:
3636
runs-on: ubuntu-24.04
37+
needs: lint
3738
steps:
3839
- name: Check out the codebase.
3940
uses: actions/checkout@v4
@@ -53,7 +54,7 @@ jobs:
5354
needs: [ setup-environment ]
5455
strategy:
5556
matrix:
56-
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
57+
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le", "binaries-windows_amd64" ]
5758
steps:
5859
- name: Check out the codebase.
5960
uses: actions/checkout@v4
@@ -77,6 +78,7 @@ jobs:
7778
7879
agent-bundle-linux:
7980
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
81+
needs: lint
8082
strategy:
8183
matrix:
8284
ARCH: [ "amd64", "arm64" ]
@@ -141,6 +143,112 @@ jobs:
141143
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
142144
path: ./dist/splunk-otel-collector*
143145

146+
agent-bundle-windows:
147+
needs: lint
148+
runs-on: ${{ matrix.OS }}
149+
strategy:
150+
matrix:
151+
OS: [ "windows-2025" ]
152+
env:
153+
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
154+
steps:
155+
- uses: actions/checkout@v4
156+
157+
- uses: actions/cache@v4
158+
with:
159+
path: ${{ env.PIP_CACHE_DIR }}
160+
key: agent-bundle-windows-pip-${{ hashFiles('packaging/bundle/collectd-plugins.yaml', 'packaging/bundle/scripts/requirements.txt') }}
161+
162+
- run: ./packaging/bundle/scripts/windows/make.ps1 bundle
163+
164+
- uses: actions/upload-artifact@v4
165+
with:
166+
name: agent-bundle-windows-${{ matrix.OS }}
167+
path: ./dist/agent-bundle_windows_amd64.zip
168+
169+
msi-custom-actions:
170+
runs-on: windows-2025
171+
needs: lint
172+
steps:
173+
- name: Check out the codebase.
174+
uses: actions/checkout@v4
175+
176+
- name: Uninstall default WiX
177+
run: choco uninstall wixtoolset
178+
179+
- name: Install WiX 3.14.0
180+
run: choco install wixtoolset --version 3.14.0 --allow-downgrade --force
181+
182+
- name: Build Custom Actions
183+
working-directory: packaging/msi/SplunkCustomActions
184+
run: |
185+
dotnet test ./test/SplunkCustomActionsTests.csproj -c Release
186+
dotnet publish ./src/SplunkCustomActions.csproj -c Release -o ./bin/Release
187+
188+
- name: Package Custom Actions
189+
run: |
190+
$WixPath = "${Env:ProgramFiles(x86)}\WiX Toolset v3.14"
191+
$sfxcaDll = "${WixPath}\SDK\x64\sfxca.dll"
192+
$Env:PATH = "${WixPath}\SDK;" + $Env:PATH
193+
$customActionDir = "${PWD}\packaging\msi\SplunkCustomActions"
194+
$customActionBinDir = "${customActionDir}\bin\Release"
195+
MakeSfxCA.exe "${PWD}\dist\SplunkCustomActions.CA.dll" `
196+
"${sfxcaDll}" `
197+
"${customActionBinDir}\SplunkCustomActions.dll" `
198+
"${customActionBinDir}\Microsoft.Deployment.WindowsInstaller.dll" `
199+
"${customActionDir}\src\CustomAction.config"
200+
201+
- uses: actions/upload-artifact@v4
202+
with:
203+
name: msi-custom-actions
204+
path: ./dist/SplunkCustomActions.CA.dll
205+
206+
msi-build:
207+
runs-on: ubuntu-24.04
208+
env:
209+
WINDOWS_VER: "windows-2025"
210+
needs: [cross-compile, agent-bundle-windows, msi-custom-actions]
211+
steps:
212+
- name: Check out the codebase.
213+
uses: actions/checkout@v4
214+
with:
215+
fetch-depth: 0
216+
217+
- name: Downloading binaries-windows_amd64
218+
uses: actions/download-artifact@v4
219+
with:
220+
name: binaries-windows_amd64
221+
path: ./bin
222+
223+
- name: Set up Go
224+
uses: actions/setup-go@v5
225+
with:
226+
go-version: ${{ env.GO_VERSION }}
227+
cache-dependency-path: '**/go.sum'
228+
229+
- name: Downloading agent-bundle-windows
230+
uses: actions/download-artifact@v4
231+
with:
232+
name: agent-bundle-windows-${{ env.WINDOWS_VER }}
233+
path: ./dist
234+
235+
- name: Downloading msi-custom-actions
236+
uses: actions/download-artifact@v4
237+
with:
238+
name: msi-custom-actions
239+
path: ./packaging/msi/SplunkCustomActions/bin/Release
240+
241+
- name: Build MSI
242+
run: |
243+
mkdir -p dist
244+
make msi SKIP_COMPILE=true VERSION=""
245+
246+
- name: Uploading msi build artifacts
247+
uses: actions/upload-artifact@v4
248+
with:
249+
name: msi-build
250+
path: ./dist/*.msi
251+
144252
lint:
145253
name: Lint
146254
runs-on: ubuntu-24.04
@@ -228,7 +336,7 @@ jobs:
228336

229337
windows-test:
230338
name: Windows Test
231-
needs: lint
339+
needs: [lint, msi-build]
232340
runs-on: ubuntu-24.04
233341
defaults:
234342
run:
@@ -257,6 +365,14 @@ jobs:
257365
- name: Check out the codebase.
258366
uses: actions/checkout@v4
259367

368+
- name: Make tmp directory for msi build artifact
369+
run: mkdir -p /tmp/msi-build
370+
371+
- uses: actions/download-artifact@v4
372+
with:
373+
name: msi-build
374+
path: /tmp/msi-build
375+
260376
- name: Install vagrant and virtualbox
261377
run: |
262378
sudo apt update && sudo apt install -y virtualbox

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
hosts: all
44
become: no
55
vars:
6+
local_artifact_testing_enabled: true
67
splunk_access_token: fake-token
78
splunk_ingest_url: https://fake-splunk-ingest.com
89
splunk_api_url: https://fake-splunk-api.com

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

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

48-
- name: Download splunk-otel-collector 0.126.0 MSI
49-
ansible.windows.win_get_url:
50-
url: https://dl.signalfx.com/splunk-otel-collector/msi/release/splunk-otel-collector-0.126.0-amd64.msi
51-
dest: "{{ansible_env.TEMP}}"
52-
register: otel_msi_package
53-
54-
- name: Install splunk-otel-collector 0.126.0 MSI
55-
ansible.windows.win_package:
56-
path: "{{otel_msi_package.dest}}"
57-
state: present
58-
check_mode: yes
59-
register: msi_installed
60-
61-
- name: Assert splunk-otel-collector 0.126.0 MSI is already installed
62-
assert:
63-
that: not msi_installed.changed
64-
6548
- name: Check custom_config.yml
6649
ansible.windows.win_stat:
6750
path: '{{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\custom_config.yml'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
hosts: all
44
become: no
55
vars:
6+
local_artifact_testing_enabled: true
67
splunk_access_token: fake-token
78
splunk_realm: fake-realm
89
tasks:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
hosts: all
44
become: no
55
vars:
6+
local_artifact_testing_enabled: true
67
splunk_access_token: fake-token
78
splunk_realm: fake-realm
89
install_fluentd: false

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

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,18 @@
11
---
22

3-
- name: Get splunk-otel-collector latest version
4-
ansible.windows.win_get_url:
5-
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/latest.txt"
6-
dest: "%TEMP%"
7-
proxy_password: "{{ win_proxy_password | default(omit) }}"
8-
proxy_url: "{{ win_proxy_url | default(omit) }}"
9-
proxy_username: "{{ win_proxy_username | default(omit) }}"
10-
use_proxy: "{{ win_use_proxy }}"
11-
register: latest
12-
when: splunk_otel_collector_version == "latest"
3+
- name: Get local MSI installer
4+
ansible.builtin.import_tasks: win_local_msi.yml
5+
when: local_artifact_testing_enabled
136

14-
- name: get content of remote file
15-
slurp:
16-
src: "{{latest.dest}}"
17-
register: version
18-
when: splunk_otel_collector_version == "latest"
19-
20-
- name: decode remote file content for latest version
21-
set_fact:
22-
splunk_otel_collector_version: "{{version.content | b64decode }}"
23-
when: splunk_otel_collector_version == "latest"
7+
- name: Get remote MSI installer
8+
ansible.builtin.import_tasks: win_download_remote_msi.yml
9+
when: not local_artifact_testing_enabled
2410

2511
- name: Use MSI capabilities to install the collector if possible
2612
set_fact:
2713
splunk_collector_msi_is_configurable: true
28-
when: splunk_otel_collector_version is version('0.98.0', '>=')
29-
30-
- name: Get splunk-otel-collector for windows
31-
ansible.windows.win_get_url:
32-
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/splunk-otel-collector-\
33-
{{splunk_otel_collector_version}}-amd64.msi"
34-
dest: "%TEMP%"
35-
proxy_password: "{{ win_proxy_password | default(omit) }}"
36-
proxy_url: "{{ win_proxy_url | default(omit) }}"
37-
proxy_username: "{{ win_proxy_username | default(omit) }}"
38-
use_proxy: "{{ win_use_proxy }}"
39-
register: otel_msi_package
14+
when:
15+
- local_artifact_testing_enabled or splunk_otel_collector_version is version('0.98.0', '>=')
4016

4117
- name: Build the arguments for the MSI installer
4218
when: splunk_collector_msi_is_configurable is defined
@@ -95,14 +71,14 @@
9571
- name: Install splunk-otel-collector-msi
9672
when: splunk_collector_msi_is_configurable is defined
9773
ansible.windows.win_package:
98-
path: "{{ otel_msi_package.dest }}"
74+
path: "{{ msi_path }}"
9975
state: present
10076
arguments: "{{ msi_arguments }}"
10177

10278
- name: Install splunk-otel-collector-msi-legacy
10379
when: splunk_collector_msi_is_configurable is undefined
10480
ansible.windows.win_package:
105-
path: "{{otel_msi_package.dest}}"
81+
path: "{{ msi_path }}"
10682
state: present
10783

10884
- name: Merge custom config into the default config
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
3+
- name: Get splunk-otel-collector latest version
4+
ansible.windows.win_get_url:
5+
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/latest.txt"
6+
dest: "%TEMP%"
7+
proxy_password: "{{ win_proxy_password | default(omit) }}"
8+
proxy_url: "{{ win_proxy_url | default(omit) }}"
9+
proxy_username: "{{ win_proxy_username | default(omit) }}"
10+
use_proxy: "{{ win_use_proxy }}"
11+
register: latest
12+
when: splunk_otel_collector_version == "latest"
13+
14+
- name: get content of remote file
15+
slurp:
16+
src: "{{latest.dest}}"
17+
register: version
18+
when: splunk_otel_collector_version == "latest"
19+
20+
- name: decode remote file content for latest version
21+
set_fact:
22+
splunk_otel_collector_version: "{{version.content | b64decode }}"
23+
when: splunk_otel_collector_version == "latest"
24+
25+
- name: Get splunk-otel-collector for windows
26+
ansible.windows.win_get_url:
27+
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/splunk-otel-collector-\
28+
{{splunk_otel_collector_version}}-amd64.msi"
29+
dest: "%TEMP%"
30+
proxy_password: "{{ win_proxy_password | default(omit) }}"
31+
proxy_url: "{{ win_proxy_url | default(omit) }}"
32+
proxy_username: "{{ win_proxy_username | default(omit) }}"
33+
use_proxy: "{{ win_use_proxy }}"
34+
register: otel_msi_package
35+
36+
- name: Set MSI source path (remote install)
37+
when: not local_artifact_testing_enabled
38+
set_fact:
39+
msi_path: "{{ otel_msi_package.dest }}"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
- set_fact:
4+
win_temp_msi_dir: "%TEMP%\\msi-build"
5+
6+
- name: Create temporary MSI build directory
7+
ansible.windows.win_file:
8+
path: win_temp_msi_dir
9+
state: directory
10+
11+
- name: Move local MSI installer to target machine
12+
ansible.windows.win_copy:
13+
src: /tmp/msi-build/
14+
dest: win_temp_msi_dir
15+
register: otel_msi_package
16+
17+
- name: Get target machine path to MSI
18+
ansible.windows.win_find:
19+
paths: win_temp_msi_dir
20+
register: msi_dir_contents
21+
failed_when: msi_dir_contents.files is not defined or msi_dir_contents.files | length != 1
22+
23+
- name: Set MSI source path (local install)
24+
when: local_artifact_testing_enabled
25+
set_fact:
26+
msi_path: "{{ msi_dir_contents.files[0].path }}"

0 commit comments

Comments
 (0)