Skip to content

Commit 0f83433

Browse files
authored
[chore][ansible] Update linux tests to use locally built artifact (#6284)
* [chore][ansible] Update linux tests to use locally built artifact * Set working directory to be a job-specific default * fix download artifact to download all, add local debian install also removed msi install * install collector via local package on Suse and RedHat * fix ansible lint: newline required at end of file * ansible_facts.ansible_architecture -> otel_collector_arch * otel_collector_arch -> ansible_architecture * convert CPU architecture from ansible string to amd64 or arm64 to match package names * mount local /tmp on molecule docker container to make packages available * remove mount, copy deb/rpm files from controller to remote instead * Copy file to generic named directory, not package name directory * Unarchive deb package before moving to remote * Don't unarchive, just copy and save dest file path * ansible lint: make variable reference expanded rather than string * Install GPG key even when local install for fluentd, update RPM copy logic * Disable GPG check for local RPM files * remove out of date config and version check * handle changed log format, revert action names * Add apt repo even if local install - accounts for autoinstrumentation * Fix instrumentation variables, taken from PR #6265 * Add yum and zypper package lists for autoinstrumentation, even when local install * revert Windows change, will be handled in separate PR * change auto_instrumentation version in test to latest, debug version * Copy default job, but use set collector version without local install * fix ansible lint * fix ansible lint * Add default remote install windows molecule test * install_local_artifact -> local_artifact_testing_enabled
1 parent ac9bcf8 commit 0f83433

File tree

30 files changed

+387
-10
lines changed

30 files changed

+387
-10
lines changed

.github/workflows/ansible.yml

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,125 @@ concurrency:
2828
permissions:
2929
contents: write
3030

31-
defaults:
32-
run:
33-
working-directory: 'deployments/ansible'
31+
env:
32+
GO_VERSION: 1.23.8
3433

3534
jobs:
35+
setup-environment:
36+
runs-on: ubuntu-24.04
37+
steps:
38+
- name: Check out the codebase.
39+
uses: actions/checkout@v4
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
cache-dependency-path: '**/go.sum'
46+
47+
- name: Installing dependency
48+
run: |
49+
make install-tools
50+
51+
cross-compile:
52+
runs-on: ubuntu-24.04
53+
needs: [ setup-environment ]
54+
strategy:
55+
matrix:
56+
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
57+
steps:
58+
- name: Check out the codebase.
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ env.GO_VERSION }}
65+
cache-dependency-path: '**/go.sum'
66+
67+
- name: Build Collector
68+
run: |
69+
make ${{ matrix.SYS_BINARIES }}
70+
71+
- name: Uploading binaries
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ${{ matrix.SYS_BINARIES }}
75+
path: |
76+
./bin/*
77+
78+
agent-bundle-linux:
79+
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
80+
strategy:
81+
matrix:
82+
ARCH: [ "amd64", "arm64" ]
83+
fail-fast: false
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- uses: actions/cache@v4
88+
id: bundle-cache
89+
with:
90+
path: .cache/buildx/agent-bundle-${{ matrix.ARCH }}
91+
key: agent-bundle-buildx-${{ matrix.ARCH }}-${{ hashFiles('packaging/bundle/**') }}
92+
restore-keys: |
93+
agent-bundle-buildx-${{ matrix.ARCH }}-
94+
95+
- run: make -C packaging/bundle agent-bundle-linux ARCH=${{ matrix.ARCH }}
96+
env:
97+
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"
98+
99+
- uses: actions/upload-artifact@v4
100+
with:
101+
name: agent-bundle-linux-${{ matrix.ARCH }}
102+
path: ./dist/agent-bundle_linux_${{ matrix.ARCH }}.tar.gz
103+
104+
build-package:
105+
runs-on: ubuntu-24.04
106+
needs: [ cross-compile, agent-bundle-linux ]
107+
strategy:
108+
matrix:
109+
SYS_PACKAGE: [ "deb", "rpm", "tar" ]
110+
ARCH: [ "amd64", "arm64" ]
111+
fail-fast: false
112+
steps:
113+
- name: Check out the codebase.
114+
uses: actions/checkout@v4
115+
with:
116+
fetch-depth: 0
117+
118+
- name: Set up Go
119+
uses: actions/setup-go@v5
120+
with:
121+
go-version: ${{ env.GO_VERSION }}
122+
cache-dependency-path: '**/go.sum'
123+
124+
- name: Downloading binaries-linux_${{ matrix.ARCH }}
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: binaries-linux_${{ matrix.ARCH }}
128+
path: ./bin
129+
130+
- uses: actions/download-artifact@v4
131+
with:
132+
name: agent-bundle-linux-${{ matrix.ARCH }}
133+
path: ./dist
134+
135+
- name: Build ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package
136+
run: make ${{ matrix.SYS_PACKAGE }}-package SKIP_COMPILE=true SKIP_BUNDLE=true VERSION="" ARCH="${{ matrix.ARCH }}"
137+
138+
- name: Uploading ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package artifacts
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
142+
path: ./dist/splunk-otel-collector*
36143

37144
lint:
38145
name: Lint
39146
runs-on: ubuntu-24.04
147+
defaults:
148+
run:
149+
working-directory: 'deployments/ansible'
40150
steps:
41151
- name: Check out the codebase.
42152
uses: actions/checkout@v4
@@ -54,8 +164,11 @@ jobs:
54164

55165
linux-test:
56166
name: Linux Test
57-
needs: lint
167+
needs: [lint, build-package]
58168
runs-on: ubuntu-24.04
169+
defaults:
170+
run:
171+
working-directory: 'deployments/ansible'
59172
strategy:
60173
fail-fast: false
61174
matrix:
@@ -75,6 +188,10 @@ jobs:
75188
- name: Check out the codebase.
76189
uses: actions/checkout@v4
77190

191+
- uses: actions/download-artifact@v4
192+
with:
193+
path: /tmp
194+
78195
- uses: DamianReeves/[email protected]
79196
with:
80197
path: "${{ github.workspace }}/requirements.txt"
@@ -113,6 +230,9 @@ jobs:
113230
name: Windows Test
114231
needs: lint
115232
runs-on: ubuntu-24.04
233+
defaults:
234+
run:
235+
working-directory: 'deployments/ansible'
116236
timeout-minutes: 60
117237
strategy:
118238
fail-fast: false
@@ -127,6 +247,7 @@ jobs:
127247
- "2022"
128248
scenario:
129249
- default
250+
- default_install_remote_version
130251
- custom_vars
131252
- with_instrumentation
132253
steps:
@@ -198,6 +319,9 @@ jobs:
198319
name: Push Release Tag
199320
needs: lint
200321
runs-on: ubuntu-24.04
322+
defaults:
323+
run:
324+
working-directory: 'deployments/ansible'
201325
if: github.ref == 'refs/heads/main'
202326
steps:
203327
- name: Checkout

deployments/ansible/molecule/custom_vars/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: yes
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/verify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@
8282
- name: Populate package facts
8383
ansible.builtin.package_facts:
8484

85-
- name: Assert specified version of splunk-otel-collector is installed
86-
assert:
87-
that: ansible_facts.packages['splunk-otel-collector'][0].version == '0.126.0'
88-
8985
- name: Assert custom service user is set
9086
ansible.builtin.lineinfile:
9187
line: User=custom-user

deployments/ansible/molecule/default/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: yes
55
vars:
6+
local_artifact_testing_enabled: true
67
splunk_access_token: fake-token
78
splunk_realm: fake-realm
89
start_service: false
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{% if item.image not in ["opensuse12", "opensuse15", "centos9"] %}
2+
FROM geerlingguy/docker-{{ item.image }}-ansible:latest
3+
{% elif item.image == "centos9" %}
4+
FROM quay.io/centos/centos:stream9
5+
ENV container docker
6+
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
7+
RUN dnf install -y initscripts sudo systemd
8+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
9+
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
10+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
11+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
12+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
13+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
14+
rm -f /lib/systemd/system/basic.target.wants/*;\
15+
rm -f /lib/systemd/system/anaconda.target.wants/*;
16+
# Disable requiretty.
17+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
18+
CMD ["/usr/sbin/init"]
19+
{% else %}
20+
{% if item.image == "opensuse12" %}
21+
FROM opensuse/leap:42
22+
RUN sed -i 's|download.opensuse.org|ftp5.gwdg.de/pub/opensuse/discontinued|' /etc/zypp/repos.d/*.repo
23+
RUN zypper -n clean && zypper -n refresh
24+
RUN zypper -n install -l ansible dbus-1 rpm-python sudo systemd-sysvinit
25+
{% else %}
26+
FROM opensuse/leap:15
27+
RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo
28+
RUN zypper -n install -l ansible dbus-1 python3-rpm sudo systemd-sysvinit
29+
{% endif %}
30+
31+
ENV container docker
32+
33+
RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
34+
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
35+
rm -f /usr/lib/systemd/system/multi-user.target.wants/*;\
36+
rm -f /usr/lib/systemd/system/local-fs.target.wants/*; \
37+
rm -f /usr/lib/systemd/system/sockets.target.wants/*udev*; \
38+
rm -f /usr/lib/systemd/system/sockets.target.wants/*initctl*; \
39+
rm -f /usr/lib/systemd/system/basic.target.wants/*;
40+
41+
# Disable requiretty.
42+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
43+
44+
# Install Ansible inventory file.
45+
RUN mkdir -p /etc/ansible
46+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
47+
48+
VOLUME [ "/sys/fs/cgroup" ]
49+
CMD ["/sbin/init"]
50+
{% endif %}
51+
52+
# Workaround for Ansible Molecule bug causing sudo actions to fail.
53+
# https://github.com/ansible/molecule/issues/4365
54+
# https://github.com/geerlingguy/docker-rockylinux9-ansible/issues/6#issuecomment-2805378491
55+
RUN chmod 0400 /etc/shadow
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: Converge scenario with the default configuration and remote version
3+
hosts: all
4+
become: yes
5+
vars:
6+
splunk_access_token: fake-token
7+
splunk_realm: fake-realm
8+
start_service: false
9+
splunk_otel_collector_version: 0.126.0
10+
tasks:
11+
- name: "Include signalfx.splunk_otel_collector.collector role"
12+
include_role:
13+
name: "signalfx.splunk_otel_collector.collector"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# no default config provided, make sure to set --base-config molecule argument instead
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
- name: Verify scenario with the default configuration
3+
hosts: all
4+
gather_facts: true
5+
tasks:
6+
7+
- name: Populate service facts
8+
ansible.builtin.service_facts:
9+
10+
- name: Assert splunk-otel-collector service is stopped
11+
assert:
12+
that: ansible_facts.services['splunk-otel-collector.service'].state == 'stopped'
13+
14+
- name: Assert td-agent service is not installed
15+
assert:
16+
that: "'td-agent.service' not in ansible_facts.services"
17+
18+
- name: Assert SPLUNK_ACCESS_TOKEN env var is set
19+
ansible.builtin.lineinfile:
20+
line: SPLUNK_ACCESS_TOKEN=fake-token
21+
dest: /etc/otel/collector/splunk-otel-collector.conf
22+
state: present
23+
check_mode: yes
24+
25+
- name: Assert SPLUNK_REALM env var is set
26+
ansible.builtin.lineinfile:
27+
line: SPLUNK_REALM=fake-realm
28+
dest: /etc/otel/collector/splunk-otel-collector.conf
29+
state: present
30+
check_mode: yes
31+
32+
- name: Assert SPLUNK_INGEST_URL env var is set
33+
ansible.builtin.lineinfile:
34+
line: SPLUNK_INGEST_URL=https://ingest.fake-realm.signalfx.com
35+
dest: /etc/otel/collector/splunk-otel-collector.conf
36+
state: present
37+
check_mode: yes
38+
39+
- name: Assert SPLUNK_API_URL env var is set
40+
ansible.builtin.lineinfile:
41+
line: SPLUNK_INGEST_URL=https://api.fake-realm.signalfx.com
42+
dest: /etc/otel/collector/splunk-otel-collector.conf
43+
state: present
44+
check_mode: yes
45+
46+
- name: Assert SPLUNK_HEC_URL env var is set
47+
ansible.builtin.lineinfile:
48+
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
49+
dest: /etc/otel/collector/splunk-otel-collector.conf
50+
state: present
51+
check_mode: yes
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Converge scenario with the default configuration on Windows
3+
hosts: all
4+
become: no
5+
vars:
6+
splunk_access_token: fake-token
7+
splunk_realm: fake-realm
8+
splunk_otel_collector_version: 0.126.0
9+
tasks:
10+
- name: "Include signalfx.splunk_otel_collector.collector role"
11+
include_role:
12+
name: "signalfx.splunk_otel_collector.collector"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Prepare
3+
hosts: all
4+
gather_facts: false
5+
become: no
6+
tasks:
7+
- name: Bypass prepare stage
8+
debug:
9+
msg: Bypassing the prepare stage since the client is a Windows box
10+
changed_when: false
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
- name: Verify scenario with the default configuration
3+
hosts: all
4+
gather_facts: true
5+
become: no
6+
vars:
7+
collector_reg_values:
8+
SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml'
9+
SPLUNK_ACCESS_TOKEN: fake-token
10+
SPLUNK_REALM: fake-realm
11+
SPLUNK_API_URL: https://api.fake-realm.signalfx.com
12+
SPLUNK_HEC_TOKEN: fake-token
13+
SPLUNK_HEC_URL: https://ingest.fake-realm.signalfx.com/v1/log
14+
SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com
15+
tasks:
16+
- name: Check splunk-otel-collector service
17+
ansible.windows.win_service:
18+
name: splunk-otel-collector
19+
state: started
20+
check_mode: yes
21+
register: service_status
22+
23+
- name: Check fluentdwinsvc service
24+
ansible.windows.win_service:
25+
name: fluentdwinsvc
26+
state: absent
27+
check_mode: yes
28+
register: service_status
29+
30+
- name: Assert fluentdwinsvc service does not exist
31+
assert:
32+
that: not service_status.exists
33+
34+
- name: Get splunk-otel-collector service env vars
35+
ansible.windows.win_reg_stat:
36+
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
37+
name: Environment
38+
register: collector_env
39+
40+
- name: Verify splunk-otel-collector service env vars
41+
assert:
42+
that: (item.key + '=' + (item.value | string)) in collector_env.value
43+
loop: "{{ collector_reg_values | dict2items }}"

0 commit comments

Comments
 (0)