Skip to content

[chore][ansible] Update linux tests to use locally built artifact #6284

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
abc9629
[chore][ansible] Update linux tests to use locally built artifact
crobert-1 Jun 2, 2025
db9ee90
Set working directory to be a job-specific default
crobert-1 Jun 2, 2025
5629283
fix download artifact to download all, add local debian install
crobert-1 Jun 2, 2025
bd45395
install collector via local package on Suse and RedHat
crobert-1 Jun 2, 2025
4798a3f
fix ansible lint: newline required at end of file
crobert-1 Jun 2, 2025
4915914
ansible_facts.ansible_architecture -> otel_collector_arch
crobert-1 Jun 3, 2025
f9f964a
otel_collector_arch -> ansible_architecture
crobert-1 Jun 3, 2025
b4fbab0
convert CPU architecture from ansible string to amd64 or arm64 to mat…
crobert-1 Jun 3, 2025
e052bbd
mount local /tmp on molecule docker container to make packages available
crobert-1 Jun 3, 2025
55b7f63
remove mount, copy deb/rpm files from controller to remote instead
crobert-1 Jun 3, 2025
2886914
Copy file to generic named directory, not package name directory
crobert-1 Jun 3, 2025
eb55e35
Unarchive deb package before moving to remote
crobert-1 Jun 3, 2025
4cdfb47
Don't unarchive, just copy and save dest file path
crobert-1 Jun 3, 2025
9f8c649
ansible lint: make variable reference expanded rather than string
crobert-1 Jun 3, 2025
b6969fb
Install GPG key even when local install for fluentd, update RPM copy …
crobert-1 Jun 3, 2025
9e05524
Disable GPG check for local RPM files
crobert-1 Jun 3, 2025
155c47d
remove out of date config and version check
crobert-1 Jun 3, 2025
1f8c9f8
handle changed log format, revert action names
crobert-1 Jun 3, 2025
f03dc7a
Add apt repo even if local install - accounts for autoinstrumentation
crobert-1 Jun 3, 2025
3bc254b
Fix instrumentation variables, taken from PR #6265
crobert-1 Jun 3, 2025
43286af
Add yum and zypper package lists for autoinstrumentation, even when l…
crobert-1 Jun 3, 2025
abc41a2
revert Windows change, will be handled in separate PR
crobert-1 Jun 4, 2025
74ecbf6
Merge branch 'main' into ansible_test_using_head
crobert-1 Jun 4, 2025
e35abfe
change auto_instrumentation version in test to latest, debug version
crobert-1 Jun 4, 2025
42278b8
Copy default job, but use set collector version without local install
crobert-1 Jun 4, 2025
1880baa
fix ansible lint
crobert-1 Jun 4, 2025
e3c3ae7
fix ansible lint
crobert-1 Jun 4, 2025
7654ea1
Add default remote install windows molecule test
crobert-1 Jun 4, 2025
a784707
install_local_artifact -> local_artifact_testing_enabled
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
132 changes: 128 additions & 4 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,125 @@ concurrency:
permissions:
contents: write

defaults:
run:
working-directory: 'deployments/ansible'
env:
GO_VERSION: 1.23.8

jobs:
setup-environment:
runs-on: ubuntu-24.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v4

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

- name: Installing dependency
run: |
make install-tools

cross-compile:
runs-on: ubuntu-24.04
needs: [ setup-environment ]
strategy:
matrix:
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4

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

- name: Build Collector
run: |
make ${{ matrix.SYS_BINARIES }}

- name: Uploading binaries
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.SYS_BINARIES }}
path: |
./bin/*

agent-bundle-linux:
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
id: bundle-cache
with:
path: .cache/buildx/agent-bundle-${{ matrix.ARCH }}
key: agent-bundle-buildx-${{ matrix.ARCH }}-${{ hashFiles('packaging/bundle/**') }}
restore-keys: |
agent-bundle-buildx-${{ matrix.ARCH }}-

- run: make -C packaging/bundle agent-bundle-linux ARCH=${{ matrix.ARCH }}
env:
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"

- uses: actions/upload-artifact@v4
with:
name: agent-bundle-linux-${{ matrix.ARCH }}
path: ./dist/agent-bundle_linux_${{ matrix.ARCH }}.tar.gz

build-package:
runs-on: ubuntu-24.04
needs: [ cross-compile, agent-bundle-linux ]
strategy:
matrix:
SYS_PACKAGE: [ "deb", "rpm", "tar" ]
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Downloading binaries-linux_${{ matrix.ARCH }}
uses: actions/download-artifact@v4
with:
name: binaries-linux_${{ matrix.ARCH }}
path: ./bin

- uses: actions/download-artifact@v4
with:
name: agent-bundle-linux-${{ matrix.ARCH }}
path: ./dist

- name: Build ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package
run: make ${{ matrix.SYS_PACKAGE }}-package SKIP_COMPILE=true SKIP_BUNDLE=true VERSION="" ARCH="${{ matrix.ARCH }}"

- name: Uploading ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
path: ./dist/splunk-otel-collector*

lint:
name: Lint
runs-on: ubuntu-24.04
defaults:
run:
working-directory: 'deployments/ansible'
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
Expand All @@ -54,8 +164,11 @@ jobs:

linux-test:
name: Linux Test
needs: lint
needs: [lint, build-package]
runs-on: ubuntu-24.04
defaults:
run:
working-directory: 'deployments/ansible'
strategy:
fail-fast: false
matrix:
Expand All @@ -75,6 +188,10 @@ jobs:
- name: Check out the codebase.
uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
path: /tmp

- uses: DamianReeves/[email protected]
with:
path: "${{ github.workspace }}/requirements.txt"
Expand Down Expand Up @@ -113,6 +230,9 @@ jobs:
name: Windows Test
needs: lint
runs-on: ubuntu-24.04
defaults:
run:
working-directory: 'deployments/ansible'
timeout-minutes: 60
strategy:
fail-fast: false
Expand All @@ -127,6 +247,7 @@ jobs:
- "2022"
scenario:
- default
- default_install_remote_version
- custom_vars
- with_instrumentation
steps:
Expand Down Expand Up @@ -198,6 +319,9 @@ jobs:
name: Push Release Tag
needs: lint
runs-on: ubuntu-24.04
defaults:
run:
working-directory: 'deployments/ansible'
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions deployments/ansible/molecule/custom_vars/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
become: yes
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
4 changes: 0 additions & 4 deletions deployments/ansible/molecule/custom_vars/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
- name: Populate package facts
ansible.builtin.package_facts:

- name: Assert specified version of splunk-otel-collector is installed
assert:
that: ansible_facts.packages['splunk-otel-collector'][0].version == '0.126.0'

- name: Assert custom service user is set
ansible.builtin.lineinfile:
line: User=custom-user
Expand Down
1 change: 1 addition & 0 deletions deployments/ansible/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
become: yes
vars:
local_artifact_testing_enabled: true
splunk_access_token: fake-token
splunk_realm: fake-realm
start_service: false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% if item.image not in ["opensuse12", "opensuse15", "centos9"] %}
FROM geerlingguy/docker-{{ item.image }}-ansible:latest
{% elif item.image == "centos9" %}
FROM quay.io/centos/centos:stream9
ENV container docker
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
RUN dnf install -y initscripts sudo systemd
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Disable requiretty.
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
CMD ["/usr/sbin/init"]
{% else %}
{% if item.image == "opensuse12" %}
FROM opensuse/leap:42
RUN sed -i 's|download.opensuse.org|ftp5.gwdg.de/pub/opensuse/discontinued|' /etc/zypp/repos.d/*.repo
RUN zypper -n clean && zypper -n refresh
RUN zypper -n install -l ansible dbus-1 rpm-python sudo systemd-sysvinit
{% else %}
FROM opensuse/leap:15
RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo
RUN zypper -n install -l ansible dbus-1 python3-rpm sudo systemd-sysvinit
{% endif %}

ENV container docker

RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
rm -f /usr/lib/systemd/system/multi-user.target.wants/*;\
rm -f /usr/lib/systemd/system/local-fs.target.wants/*; \
rm -f /usr/lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /usr/lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /usr/lib/systemd/system/basic.target.wants/*;

# Disable requiretty.
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers

# Install Ansible inventory file.
RUN mkdir -p /etc/ansible
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts

VOLUME [ "/sys/fs/cgroup" ]
CMD ["/sbin/init"]
{% endif %}

# Workaround for Ansible Molecule bug causing sudo actions to fail.
# https://github.com/ansible/molecule/issues/4365
# https://github.com/geerlingguy/docker-rockylinux9-ansible/issues/6#issuecomment-2805378491
RUN chmod 0400 /etc/shadow
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Converge scenario with the default configuration and remote version
hosts: all
become: yes
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
start_service: false
splunk_otel_collector_version: 0.126.0
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "signalfx.splunk_otel_collector.collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no default config provided, make sure to set --base-config molecule argument instead
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
- name: Verify scenario with the default configuration
hosts: all
gather_facts: true
tasks:

- name: Populate service facts
ansible.builtin.service_facts:

- name: Assert splunk-otel-collector service is stopped
assert:
that: ansible_facts.services['splunk-otel-collector.service'].state == 'stopped'

- name: Assert td-agent service is not installed
assert:
that: "'td-agent.service' not in ansible_facts.services"

- name: Assert SPLUNK_ACCESS_TOKEN env var is set
ansible.builtin.lineinfile:
line: SPLUNK_ACCESS_TOKEN=fake-token
dest: /etc/otel/collector/splunk-otel-collector.conf
state: present
check_mode: yes

- name: Assert SPLUNK_REALM env var is set
ansible.builtin.lineinfile:
line: SPLUNK_REALM=fake-realm
dest: /etc/otel/collector/splunk-otel-collector.conf
state: present
check_mode: yes

- name: Assert SPLUNK_INGEST_URL env var is set
ansible.builtin.lineinfile:
line: SPLUNK_INGEST_URL=https://ingest.fake-realm.signalfx.com
dest: /etc/otel/collector/splunk-otel-collector.conf
state: present
check_mode: yes

- name: Assert SPLUNK_API_URL env var is set
ansible.builtin.lineinfile:
line: SPLUNK_INGEST_URL=https://api.fake-realm.signalfx.com
dest: /etc/otel/collector/splunk-otel-collector.conf
state: present
check_mode: yes

- name: Assert SPLUNK_HEC_URL env var is set
ansible.builtin.lineinfile:
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
dest: /etc/otel/collector/splunk-otel-collector.conf
state: present
check_mode: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Converge scenario with the default configuration on Windows
hosts: all
become: no
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
splunk_otel_collector_version: 0.126.0
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "signalfx.splunk_otel_collector.collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Prepare
hosts: all
gather_facts: false
become: no
tasks:
- name: Bypass prepare stage
debug:
msg: Bypassing the prepare stage since the client is a Windows box
changed_when: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: Verify scenario with the default configuration
hosts: all
gather_facts: true
become: no
vars:
collector_reg_values:
SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml'
SPLUNK_ACCESS_TOKEN: fake-token
SPLUNK_REALM: fake-realm
SPLUNK_API_URL: https://api.fake-realm.signalfx.com
SPLUNK_HEC_TOKEN: fake-token
SPLUNK_HEC_URL: https://ingest.fake-realm.signalfx.com/v1/log
SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com
tasks:
- name: Check splunk-otel-collector service
ansible.windows.win_service:
name: splunk-otel-collector
state: started
check_mode: yes
register: service_status

- name: Check fluentdwinsvc service
ansible.windows.win_service:
name: fluentdwinsvc
state: absent
check_mode: yes
register: service_status

- name: Assert fluentdwinsvc service does not exist
assert:
that: not service_status.exists

- name: Get splunk-otel-collector service env vars
ansible.windows.win_reg_stat:
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
name: Environment
register: collector_env

- name: Verify splunk-otel-collector service env vars
assert:
that: (item.key + '=' + (item.value | string)) in collector_env.value
loop: "{{ collector_reg_values | dict2items }}"
Loading
Loading