Skip to content

[chore][ansible] Run Windows tests against current build #6309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d6690c1
[chore][ansible] Use locally built artifact for Windows testing
crobert-1 Jun 12, 2025
1f10185
set `needs` for windows testing
crobert-1 Jun 12, 2025
2e69c8d
add task helper
crobert-1 Jun 12, 2025
87f1ab7
Use job env rather than single entry matrix
crobert-1 Jun 12, 2025
b393c9a
fix windows var reference
crobert-1 Jun 12, 2025
d7532bd
upload file with expected name
crobert-1 Jun 12, 2025
f20e6f7
download all artifacts
crobert-1 Jun 12, 2025
6e3b1d5
View all contents of /tmp
crobert-1 Jun 12, 2025
01ce57a
use win_copy instead of builtin copy
crobert-1 Jun 12, 2025
593fd26
download all artifacts
crobert-1 Jun 12, 2025
56f47c4
block all ansible tests on lint
crobert-1 Jun 12, 2025
9596b88
block another job on lint
crobert-1 Jun 12, 2025
a234c59
don't care about collector ver if testing local artifact
crobert-1 Jun 12, 2025
a62631e
debugging paths and file names
crobert-1 Jun 12, 2025
3d70310
use ansible find for filename in controller
crobert-1 Jun 12, 2025
5108c8c
fix failed_when syntax
crobert-1 Jun 12, 2025
d42e0cd
use win_find on target machine to get filename of MSI
crobert-1 Jun 13, 2025
066903e
fix ansible lint: double quotes around temp and string
crobert-1 Jun 13, 2025
48d89b9
fix escaped backslashes in double quotes
crobert-1 Jun 13, 2025
2b3a4d4
more stat, use task for creating temp dir
crobert-1 Jun 13, 2025
fe7f5ec
fix ansible lint: indent debug variable
crobert-1 Jun 13, 2025
48bc406
properly expand variable
crobert-1 Jun 13, 2025
cfc41e8
fix path finding
crobert-1 Jun 13, 2025
6cc19fd
fix variable expansion
crobert-1 Jun 13, 2025
4ad7081
move to win_file instead of wintemp for idempotency
crobert-1 Jun 16, 2025
f80aea6
two backslashes inside of double quotes
crobert-1 Jun 16, 2025
9af78f6
move local install to its own yml, use reusable temp path fact
crobert-1 Jun 16, 2025
b2d5633
Remove debugging, as well as version-specific check
crobert-1 Jun 16, 2025
590e3b1
newlines at end of files
crobert-1 Jun 16, 2025
174e4ce
Merge branch 'main' into ansible_windows_test_current_build
crobert-1 Jun 16, 2025
97fb369
Merge branch 'main' into ansible_windows_test_current_build
crobert-1 Jun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 118 additions & 2 deletions .github/workflows/ansible.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agent-bundle-windows, msi-custom-actions, and msi-build are all directly copied from https://github.com/signalfx/splunk-otel-collector/blob/main/.github/workflows/win-package-test.yml

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ env:
jobs:
setup-environment:
runs-on: ubuntu-24.04
needs: lint
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
Expand All @@ -53,7 +54,7 @@ jobs:
needs: [ setup-environment ]
strategy:
matrix:
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le", "binaries-windows_amd64" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
Expand All @@ -77,6 +78,7 @@ jobs:

agent-bundle-linux:
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
needs: lint
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
Expand Down Expand Up @@ -141,6 +143,112 @@ jobs:
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
path: ./dist/splunk-otel-collector*

agent-bundle-windows:
needs: lint
runs-on: ${{ matrix.OS }}
strategy:
matrix:
OS: [ "windows-2025" ]
env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: ${{ env.PIP_CACHE_DIR }}
key: agent-bundle-windows-pip-${{ hashFiles('packaging/bundle/collectd-plugins.yaml', 'packaging/bundle/scripts/requirements.txt') }}

- run: ./packaging/bundle/scripts/windows/make.ps1 bundle

- uses: actions/upload-artifact@v4
with:
name: agent-bundle-windows-${{ matrix.OS }}
path: ./dist/agent-bundle_windows_amd64.zip

msi-custom-actions:
runs-on: windows-2025
needs: lint
steps:
- name: Check out the codebase.
uses: actions/checkout@v4

- name: Uninstall default WiX
run: choco uninstall wixtoolset

- name: Install WiX 3.14.0
run: choco install wixtoolset --version 3.14.0 --allow-downgrade --force

- name: Build Custom Actions
working-directory: packaging/msi/SplunkCustomActions
run: |
dotnet test ./test/SplunkCustomActionsTests.csproj -c Release
dotnet publish ./src/SplunkCustomActions.csproj -c Release -o ./bin/Release

- name: Package Custom Actions
run: |
$WixPath = "${Env:ProgramFiles(x86)}\WiX Toolset v3.14"
$sfxcaDll = "${WixPath}\SDK\x64\sfxca.dll"
$Env:PATH = "${WixPath}\SDK;" + $Env:PATH
$customActionDir = "${PWD}\packaging\msi\SplunkCustomActions"
$customActionBinDir = "${customActionDir}\bin\Release"
MakeSfxCA.exe "${PWD}\dist\SplunkCustomActions.CA.dll" `
"${sfxcaDll}" `
"${customActionBinDir}\SplunkCustomActions.dll" `
"${customActionBinDir}\Microsoft.Deployment.WindowsInstaller.dll" `
"${customActionDir}\src\CustomAction.config"

- uses: actions/upload-artifact@v4
with:
name: msi-custom-actions
path: ./dist/SplunkCustomActions.CA.dll

msi-build:
runs-on: ubuntu-24.04
env:
WINDOWS_VER: "windows-2025"
needs: [cross-compile, agent-bundle-windows, msi-custom-actions]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v4
with:
name: binaries-windows_amd64
path: ./bin

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'

- name: Downloading agent-bundle-windows
uses: actions/download-artifact@v4
with:
name: agent-bundle-windows-${{ env.WINDOWS_VER }}
path: ./dist

- name: Downloading msi-custom-actions
uses: actions/download-artifact@v4
with:
name: msi-custom-actions
path: ./packaging/msi/SplunkCustomActions/bin/Release

- name: Build MSI
run: |
mkdir -p dist
make msi SKIP_COMPILE=true VERSION=""

- name: Uploading msi build artifacts
uses: actions/upload-artifact@v4
with:
name: msi-build
path: ./dist/*.msi

lint:
name: Lint
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -228,7 +336,7 @@ jobs:

windows-test:
name: Windows Test
needs: lint
needs: [lint, msi-build]
runs-on: ubuntu-24.04
defaults:
run:
Expand Down Expand Up @@ -257,6 +365,14 @@ jobs:
- name: Check out the codebase.
uses: actions/checkout@v4

- name: Make tmp directory for msi build artifact
run: mkdir -p /tmp/msi-build

- uses: actions/download-artifact@v4
with:
name: msi-build
Copy link
Contributor Author

@crobert-1 crobert-1 Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity in Ansible logic, use a single MSI with a preset name, rather than having to pass around variables and parse versions.

path: /tmp/msi-build

- name: Install vagrant and virtualbox
run: |
sudo apt update && sudo apt install -y virtualbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
become: no
vars:
local_artifact_testing_enabled: true
splunk_access_token: fake-token
splunk_ingest_url: https://fake-splunk-ingest.com
splunk_api_url: https://fake-splunk-api.com
Expand Down
17 changes: 0 additions & 17 deletions deployments/ansible/molecule/custom_vars/windows-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@
assert:
that: not service_status.changed

- name: Download splunk-otel-collector 0.126.0 MSI
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed version check for the same reason as the linux change. We can revisit if anyone has a strong preference here.

ansible.windows.win_get_url:
url: https://dl.signalfx.com/splunk-otel-collector/msi/release/splunk-otel-collector-0.126.0-amd64.msi
dest: "{{ansible_env.TEMP}}"
register: otel_msi_package

- name: Install splunk-otel-collector 0.126.0 MSI
ansible.windows.win_package:
path: "{{otel_msi_package.dest}}"
state: present
check_mode: yes
register: msi_installed

- name: Assert splunk-otel-collector 0.126.0 MSI is already installed
assert:
that: not msi_installed.changed

- name: Check custom_config.yml
ansible.windows.win_stat:
path: '{{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\custom_config.yml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
become: no
vars:
local_artifact_testing_enabled: true
splunk_access_token: fake-token
splunk_realm: fake-realm
tasks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
become: no
vars:
local_artifact_testing_enabled: true
splunk_access_token: fake-token
splunk_realm: fake-realm
install_fluentd: false
Expand Down
44 changes: 10 additions & 34 deletions deployments/ansible/roles/collector/tasks/otel_win_install.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
---

- name: Get splunk-otel-collector latest version
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted lines from this file are simply being moved to the win_download_remote_msi,yml task in the same directory.

ansible.windows.win_get_url:
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/latest.txt"
dest: "%TEMP%"
proxy_password: "{{ win_proxy_password | default(omit) }}"
proxy_url: "{{ win_proxy_url | default(omit) }}"
proxy_username: "{{ win_proxy_username | default(omit) }}"
use_proxy: "{{ win_use_proxy }}"
register: latest
when: splunk_otel_collector_version == "latest"
- name: Get local MSI installer
ansible.builtin.import_tasks: win_local_msi.yml
when: local_artifact_testing_enabled

- name: get content of remote file
slurp:
src: "{{latest.dest}}"
register: version
when: splunk_otel_collector_version == "latest"

- name: decode remote file content for latest version
set_fact:
splunk_otel_collector_version: "{{version.content | b64decode }}"
when: splunk_otel_collector_version == "latest"
- name: Get remote MSI installer
ansible.builtin.import_tasks: win_download_remote_msi.yml
when: not local_artifact_testing_enabled

- name: Use MSI capabilities to install the collector if possible
set_fact:
splunk_collector_msi_is_configurable: true
when: splunk_otel_collector_version is version('0.98.0', '>=')

- name: Get splunk-otel-collector for windows
ansible.windows.win_get_url:
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/splunk-otel-collector-\
{{splunk_otel_collector_version}}-amd64.msi"
dest: "%TEMP%"
proxy_password: "{{ win_proxy_password | default(omit) }}"
proxy_url: "{{ win_proxy_url | default(omit) }}"
proxy_username: "{{ win_proxy_username | default(omit) }}"
use_proxy: "{{ win_use_proxy }}"
register: otel_msi_package
when:
- local_artifact_testing_enabled or splunk_otel_collector_version is version('0.98.0', '>=')

- name: Build the arguments for the MSI installer
when: splunk_collector_msi_is_configurable is defined
Expand Down Expand Up @@ -95,14 +71,14 @@
- name: Install splunk-otel-collector-msi
when: splunk_collector_msi_is_configurable is defined
ansible.windows.win_package:
path: "{{ otel_msi_package.dest }}"
path: "{{ msi_path }}"
state: present
arguments: "{{ msi_arguments }}"

- name: Install splunk-otel-collector-msi-legacy
when: splunk_collector_msi_is_configurable is undefined
ansible.windows.win_package:
path: "{{otel_msi_package.dest}}"
path: "{{ msi_path }}"
state: present

- name: Merge custom config into the default config
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

- name: Get splunk-otel-collector latest version
ansible.windows.win_get_url:
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/latest.txt"
dest: "%TEMP%"
proxy_password: "{{ win_proxy_password | default(omit) }}"
proxy_url: "{{ win_proxy_url | default(omit) }}"
proxy_username: "{{ win_proxy_username | default(omit) }}"
use_proxy: "{{ win_use_proxy }}"
register: latest
when: splunk_otel_collector_version == "latest"

- name: get content of remote file
slurp:
src: "{{latest.dest}}"
register: version
when: splunk_otel_collector_version == "latest"

- name: decode remote file content for latest version
set_fact:
splunk_otel_collector_version: "{{version.content | b64decode }}"
when: splunk_otel_collector_version == "latest"

- name: Get splunk-otel-collector for windows
ansible.windows.win_get_url:
url: "{{win_base_url}}/splunk-otel-collector/msi/{{package_stage}}/splunk-otel-collector-\
{{splunk_otel_collector_version}}-amd64.msi"
dest: "%TEMP%"
proxy_password: "{{ win_proxy_password | default(omit) }}"
proxy_url: "{{ win_proxy_url | default(omit) }}"
proxy_username: "{{ win_proxy_username | default(omit) }}"
use_proxy: "{{ win_use_proxy }}"
register: otel_msi_package

- name: Set MSI source path (remote install)
when: not local_artifact_testing_enabled
set_fact:
msi_path: "{{ otel_msi_package.dest }}"
26 changes: 26 additions & 0 deletions deployments/ansible/roles/collector/tasks/win_local_msi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

- set_fact:
win_temp_msi_dir: "%TEMP%\\msi-build"

- name: Create temporary MSI build directory
ansible.windows.win_file:
path: win_temp_msi_dir
state: directory

- name: Move local MSI installer to target machine
ansible.windows.win_copy:
src: /tmp/msi-build/
dest: win_temp_msi_dir
register: otel_msi_package

- name: Get target machine path to MSI
ansible.windows.win_find:
paths: win_temp_msi_dir
register: msi_dir_contents
failed_when: msi_dir_contents.files is not defined or msi_dir_contents.files | length != 1

- name: Set MSI source path (local install)
when: local_artifact_testing_enabled
set_fact:
msi_path: "{{ msi_dir_contents.files[0].path }}"
Loading