Skip to content

[chore][ansible] Upgrade version tested for Windows #6288

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

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8619232
[chore][ansible] Upgrade version tested for Windows
crobert-1 Jun 4, 2025
811a2fe
fix ansible lint
crobert-1 Jun 4, 2025
53429e9
touch log file
crobert-1 Jun 4, 2025
e6eeeba
change log_path to be a host path (rather than windows)
crobert-1 Jun 4, 2025
8e9e52b
debug: upload msi install logs to github artifact ouput
crobert-1 Jun 4, 2025
23f2659
Don't stop ansible deploy on failure, collector log file
crobert-1 Jun 4, 2025
296d8de
change path used for win install log file
crobert-1 Jun 4, 2025
1a355b3
use absolute path without substitutes
crobert-1 Jun 4, 2025
52e5047
use unique name for log files from windows ansible msi install
crobert-1 Jun 4, 2025
00769da
fail job if molecule test fails, but still upload logs
crobert-1 Jun 4, 2025
e76c5a4
Change to show step failure, but still execute uploading of logs
crobert-1 Jun 4, 2025
0badc94
Always fetch logs as github workflow determines whether to upload them
crobert-1 Jun 4, 2025
2794a05
Only upload log files if molecule tests failed
crobert-1 Jun 4, 2025
2336c72
Upload logs even if successful molecule test
crobert-1 Jun 4, 2025
4c93952
ignoring errors, upload all matching files, not directory
crobert-1 Jun 4, 2025
908277d
attempt to add timeout to msi install
crobert-1 Jun 4, 2025
95f3022
save async results file, give github artifacts unique names
crobert-1 Jun 5, 2025
4d26367
fix upload naming to include ansible version, add more log debugging
crobert-1 Jun 5, 2025
a6674a0
add win registry variable output
crobert-1 Jun 5, 2025
a262b68
use regex replace for surrounding MSI arg values with spaces
crobert-1 Jun 5, 2025
fc2151d
all tests failed with escaped double-quotes, test un-escaped
crobert-1 Jun 5, 2025
c83f83f
no escaping failed lint, try two backslashes for escaping
crobert-1 Jun 5, 2025
7b9b18e
separate out regex and replacement strings into vars
crobert-1 Jun 5, 2025
65cdf49
double escape didn't work, the group specifiers were broken. attempt …
crobert-1 Jun 5, 2025
a738a49
only use one backslash for group replacement regex
crobert-1 Jun 5, 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
11 changes: 10 additions & 1 deletion .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,22 @@ jobs:
free -h

- name: Run Molecule tests.
run: molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }}
run: |
mkdir /tmp/log
molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }}
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_VAGRANT_BOX_URL: /tmp/vagrant.box
MOLECULE_VAGRANT_BOX_VERSION: " " # version must not be set when using a local box

- name: Uploading log files
Copy link
Contributor Author

@crobert-1 crobert-1 Jun 4, 2025

Choose a reason for hiding this comment

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

These logs are coming from the specific step of installing the MSI currently. We could potentially just upload logs on molecule test failure as that would save space, but if the failure messages aren't very clear it's helpful to have successful logs as well for comparing.

The log files aren't very big (~1.5MB each), so I think we should keep them for now.

if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ansible-molecule-windows-${{ matrix.distro }}-${{matrix.ansible}}-${{ matrix.scenario }}
path: /tmp/log/*

push-release-tag:
name: Push Release Tag
needs: lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
splunk_api_url: https://fake-splunk-api.com
splunk_hec_url: https://fake-splunk-hec.com
splunk_hec_token: fake-hec-token
splunk_otel_collector_version: 0.48.0
splunk_otel_collector_version: 0.126.0
splunk_otel_collector_config: '{{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\custom_config.yml'
splunk_otel_collector_config_source: ./custom_collector_config_deprecated.yml
splunk_memory_total_mib: 256
Expand Down
8 changes: 4 additions & 4 deletions deployments/ansible/molecule/custom_vars/windows-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@
assert:
that: not service_status.changed

- name: Download splunk-otel-collector 0.48.0 MSI
- name: Download splunk-otel-collector 0.126.0 MSI
ansible.windows.win_get_url:
url: https://dl.signalfx.com/splunk-otel-collector/msi/release/splunk-otel-collector-0.48.0-amd64.msi
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.48.0 MSI
- 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.48.0 MSI is already installed
- name: Assert splunk-otel-collector 0.126.0 MSI is already installed
assert:
that: not msi_installed.changed

Expand Down
88 changes: 87 additions & 1 deletion deployments/ansible/roles/collector/tasks/otel_win_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
use_proxy: "{{ win_use_proxy }}"
register: otel_msi_package

# TDDO: DELETE THIS
- name: Get Splunk OpenTelemetry Collector options list - legacy variables used to set registry
set_fact:
splunk_otel_collector_options_list: |-
{%- set value = item.value -%}
{{ (splunk_otel_collector_options_list | default([])) + [item.key + '=' + (value | string)] }}
loop: >
{{ splunk_otel_collector_options | default({}) | combine(splunk_otel_collector_additional_env_vars) | dict2items }}

- debug:
var: splunk_otel_collector_options_list

- name: Build the arguments for the MSI installer
when: splunk_collector_msi_is_configurable is defined
set_fact:
Expand All @@ -61,12 +73,86 @@
set_fact:
msi_arguments: "{{ msi_unfiltered_arguments | reject('eq', '') | list }}"

- debug:
var: msi_arguments

- name: Surround msi argument values wtih quotes to properly handle spaces in values
when: splunk_collector_msi_is_configurable is defined
set_fact:
msi_arguments: "{{ msi_arguments | map('regex_replace', _regex, _replacement) | list }}"
vars:
_regex: '^(.*)=(.*)$'
_replacement: '\1="\2"'


- debug:
var: msi_arguments

- name: Check my username
ansible.windows.win_whoami:
become: true

- name: Set the MSI install log path
ansible.builtin.set_fact:
msi_install_log_path: "C:\\Users\\vagrant\\AppData\\Local\\Temp\\{{ lookup('pipe', 'date +%Y%m%dT%H%M%S') }}.log"
when: splunk_collector_msi_is_configurable is defined

- name: Install splunk-otel-collector-msi
when: splunk_collector_msi_is_configurable is defined
ansible.windows.win_package:
path: "{{otel_msi_package.dest}}"
path: "{{ otel_msi_package.dest }}"
state: present
log_path: "{{ msi_install_log_path }}"
arguments: "{{ msi_arguments }}"
ignore_errors: true
register: msi_installed
async: 900 # 15 minutes
poll: 10

- debug:
var: msi_installed

- name: Stat log path for splunk-otel-collector MSI install
ansible.windows.win_stat:
path: "{{ msi_install_log_path }}"
register: msi_install_log_stat
ignore_errors: true
when: splunk_collector_msi_is_configurable is defined

- debug:
var: msi_install_log_stat

- name: Stat async results path for splunk-otel-collector MSI install
ansible.windows.win_stat:
path: "{{ msi_installed.results_file }}"
register: async_results_stat
ignore_errors: true
when: splunk_collector_msi_is_configurable is defined and msi_installed.results_file is defined

- debug:
var: async_results_stat

- name: Fetch log file from splunk-otel-collector MSI install to host
ansible.builtin.fetch:
src: "{{ msi_install_log_path }}"
dest: /tmp/log/
flat: true
ignore_errors: true
when: splunk_collector_msi_is_configurable is defined

- name: Fetch async log file from splunk-otel-collector MSI install
ansible.builtin.fetch:
src: "{{ msi_installed.results_file }}"
dest: /tmp/log/
flat: true
ignore_errors: true
when: splunk_collector_msi_is_configurable and msi_installed.results_file is defined

- name: Fail if MSI install failed
ansible.builtin.fail:
msg: "Splunk OpenTelemetry Collector MSI installation failed. Check the log file for details."
# TODO: This condition needs fixed to account for any failure other than async
when: msi_installed.rc is not defined and splunk_collector_msi_is_configurable is defined

- name: Install splunk-otel-collector-msi-legacy
when: splunk_collector_msi_is_configurable is undefined
Expand Down
Loading