Skip to content

Commit 82eaa25

Browse files
authored
[chore][ansible/molecule] Add case for old version on Windows (#6307)
* [chore][ansible/molecule] Add case for old splunk-otel-collector on Windows * rename test case * add new test case * use updated config * make new case work on linux * add custom var with spaces * fix test case name * add verification for new custom variable * Fix test issue
1 parent ae23889 commit 82eaa25

File tree

14 files changed

+472
-6
lines changed

14 files changed

+472
-6
lines changed

.github/workflows/ansible.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ jobs:
358358
- default_install_remote_version
359359
- custom_vars
360360
- with_instrumentation
361+
- custom_vars_install_old_version
361362
steps:
362363
- name: Free up disk space for vagrant box
363364
uses: jlumbroso/[email protected]

deployments/ansible/molecule/custom_vars/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
splunk_otel_collector_additional_env_vars:
2323
MY_CUSTOM_VAR1: value1
2424
MY_CUSTOM_VAR2: value2
25+
MY_CUSTOM_VAR3: "value3 with spaces"
2526
tasks:
2627
- name: "Include signalfx.splunk_otel_collector.collector role"
2728
include_role:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
splunk_otel_collector_additional_env_vars:
2222
MY_CUSTOM_VAR1: value1
2323
MY_CUSTOM_VAR2: value2
24+
MY_CUSTOM_VAR3: 'value3 with spaces'
2425
install_splunk_dotnet_auto_instrumentation: true
2526
splunk_dotnet_auto_instrumentation_version: 1.8.0
2627
splunk_dotnet_auto_instrumentation_system_wide: true
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
- name: Converge scenario with custom variables
3+
hosts: all
4+
become: yes
5+
vars:
6+
local_artifact_testing_enabled: true
7+
splunk_access_token: fake-token
8+
splunk_ingest_url: https://fake-splunk-ingest.com
9+
splunk_api_url: https://fake-splunk-api.com
10+
splunk_otel_collector_version: 0.97.0
11+
splunk_otel_collector_config: /etc/otel/collector/custom_config.yml
12+
splunk_otel_collector_config_source: ./custom_collector_config.yml
13+
splunk_service_user: custom-user
14+
splunk_service_group: custom-group
15+
splunk_memory_total_mib: 256
16+
splunk_otel_collector_command_line_args: "--discovery"
17+
gomemlimit: 230
18+
splunk_listen_interface: 1.2.3.4
19+
splunk_fluentd_config: /etc/otel/collector/fluentd/custom_fluentd.conf
20+
splunk_fluentd_config_source: ./custom_fluentd_config.conf
21+
install_fluentd: yes
22+
splunk_otel_collector_additional_env_vars:
23+
MY_CUSTOM_VAR1: value1
24+
MY_CUSTOM_VAR2: value2
25+
MY_CUSTOM_VAR3: "value3 with spaces"
26+
tasks:
27+
- name: "Include signalfx.splunk_otel_collector.collector role"
28+
include_role:
29+
name: "signalfx.splunk_otel_collector.collector"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# Custom collector config for test purposes
3+
4+
receivers:
5+
fluentforward:
6+
endpoint: 127.0.0.1:8006
7+
otlp:
8+
protocols:
9+
grpc:
10+
http:
11+
prometheus:
12+
config:
13+
scrape_configs:
14+
- job_name: 'otel-collector'
15+
scrape_interval: 10s
16+
static_configs:
17+
- targets: ['127.0.0.1:8888']
18+
19+
processors:
20+
memory_limiter:
21+
check_interval: 2s
22+
limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB}
23+
24+
exporters:
25+
debug/detailed:
26+
verbosity: detailed
27+
debug/normal:
28+
verbosity: normal
29+
30+
service:
31+
pipelines:
32+
metrics:
33+
receivers: [otlp, prometheus]
34+
processors: [memory_limiter]
35+
exporters: [debug/normal]
36+
logs:
37+
receivers: [fluentforward, otlp]
38+
processors: [memory_limiter]
39+
exporters: [debug/detailed]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Custom fluentd config for test purposes
2+
3+
<source>
4+
@type http
5+
port 9880
6+
bind 0.0.0.0
7+
body_size_limit 32m
8+
keepalive_timeout 10s
9+
</source>
10+
11+
<match **>
12+
@type forward
13+
heartbeat_type udp
14+
<server>
15+
host 127.0.0.1
16+
port 8006
17+
</server>
18+
<buffer>
19+
@type memory
20+
flush_interval 1s
21+
</buffer>
22+
</match>
23+
24+
<system>
25+
log_level info
26+
</system>
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: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
- name: Verify scenario with custom variables
3+
hosts: all
4+
gather_facts: true
5+
become: yes
6+
tasks:
7+
- name: Import shared verification tasks
8+
ansible.builtin.import_tasks: ../shared/verify_tasks.yml
9+
10+
- name: Check custom_config.yaml
11+
stat:
12+
path: /etc/otel/collector/custom_config.yml
13+
register: custom_collector_config
14+
15+
- name: Assert custom_config.yaml is created
16+
assert:
17+
that: custom_collector_config.stat.exists
18+
19+
- name: Assert custom_config.yaml is used
20+
ansible.builtin.lineinfile:
21+
line: SPLUNK_CONFIG=/etc/otel/collector/custom_config.yml
22+
dest: /etc/otel/collector/splunk-otel-collector.conf
23+
state: present
24+
check_mode: yes
25+
register: config
26+
failed_when: config is changed
27+
28+
- name: Assert SPLUNK_INGEST_URL env var is set
29+
ansible.builtin.lineinfile:
30+
line: SPLUNK_INGEST_URL=https://fake-splunk-ingest.com
31+
dest: /etc/otel/collector/splunk-otel-collector.conf
32+
state: present
33+
check_mode: yes
34+
register: config
35+
failed_when: config is changed
36+
37+
- name: Assert SPLUNK_API_URL env var is set
38+
ansible.builtin.lineinfile:
39+
line: SPLUNK_API_URL=https://fake-splunk-api.com
40+
dest: /etc/otel/collector/splunk-otel-collector.conf
41+
state: present
42+
check_mode: yes
43+
register: config
44+
failed_when: config is changed
45+
46+
- name: Assert SPLUNK_HEC_URL env var is set
47+
ansible.builtin.lineinfile:
48+
line: SPLUNK_HEC_URL=https://fake-splunk-ingest.com/v1/log
49+
dest: /etc/otel/collector/splunk-otel-collector.conf
50+
state: present
51+
check_mode: yes
52+
register: config
53+
failed_when: config is changed
54+
55+
- name: Assert OTELCOL_OPTIONS env var is set per splunk_otel_collector_command_line_args
56+
ansible.builtin.lineinfile:
57+
line: OTELCOL_OPTIONS=--discovery
58+
dest: /etc/otel/collector/splunk-otel-collector.conf
59+
state: present
60+
check_mode: yes
61+
register: config
62+
failed_when: config is changed
63+
64+
- name: Assert MY_CUSTOM_VAR1 env var is set
65+
ansible.builtin.lineinfile:
66+
line: MY_CUSTOM_VAR1=value1
67+
dest: /etc/otel/collector/splunk-otel-collector.conf
68+
state: present
69+
check_mode: yes
70+
register: config
71+
failed_when: config is changed
72+
73+
- name: Assert MY_CUSTOM_VAR2 env var is set
74+
ansible.builtin.lineinfile:
75+
line: MY_CUSTOM_VAR2=value2
76+
dest: /etc/otel/collector/splunk-otel-collector.conf
77+
state: present
78+
check_mode: yes
79+
register: config
80+
failed_when: config is changed
81+
82+
- name: Populate package facts
83+
ansible.builtin.package_facts:
84+
85+
- name: Assert custom service user is set
86+
ansible.builtin.lineinfile:
87+
line: User=custom-user
88+
dest: /etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf
89+
state: present
90+
check_mode: yes
91+
register: config
92+
failed_when: config is changed
93+
94+
- name: Assert custom service group is set
95+
ansible.builtin.lineinfile:
96+
line: Group=custom-group
97+
dest: /etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf
98+
state: present
99+
check_mode: yes
100+
register: config
101+
failed_when: config is changed
102+
103+
- name: Assert SPLUNK_MEMORY_TOTAL_MIB env var is set
104+
ansible.builtin.lineinfile:
105+
line: SPLUNK_MEMORY_TOTAL_MIB=256
106+
dest: /etc/otel/collector/splunk-otel-collector.conf
107+
state: present
108+
check_mode: yes
109+
register: config
110+
failed_when: config is changed
111+
112+
- name: Assert SPLUNK_LISTEN_INTERFACE env var is set
113+
ansible.builtin.lineinfile:
114+
line: SPLUNK_LISTEN_INTERFACE=1.2.3.4
115+
dest: /etc/otel/collector/splunk-otel-collector.conf
116+
state: present
117+
check_mode: yes
118+
register: config
119+
failed_when: config is changed
120+
121+
- name: Assert GOMEMLIMIT env var is set
122+
ansible.builtin.lineinfile:
123+
line: GOMEMLIMIT=230
124+
dest: /etc/otel/collector/splunk-otel-collector.conf
125+
state: present
126+
check_mode: yes
127+
register: config
128+
failed_when: config is changed
129+
130+
- name: Check custom_fluentd.conf
131+
stat:
132+
path: /etc/otel/collector/fluentd/custom_fluentd.conf
133+
register: custom_fluentd_config
134+
135+
- name: Assert custom_fluentd.conf is created
136+
assert:
137+
that: custom_fluentd_config.stat.exists
138+
when: fluentd_supported
139+
140+
- name: Assert custom_fluentd.conf is used
141+
ansible.builtin.lineinfile:
142+
line: Environment=FLUENT_CONF=/etc/otel/collector/fluentd/custom_fluentd.conf
143+
dest: /etc/systemd/system/td-agent.service.d/splunk-otel-collector.conf
144+
state: present
145+
check_mode: yes
146+
when: fluentd_supported
147+
register: config
148+
failed_when: config is changed
149+
150+
- name: Send a test log message
151+
ansible.builtin.uri:
152+
body: json={"log":"test logs pipeline"}
153+
method: POST
154+
url: http://localhost:9880/app.log
155+
changed_when: false
156+
when: fluentd_supported
157+
158+
- name: Look for the test log message in collector service output
159+
ansible.builtin.shell:
160+
cmd: 'journalctl -u splunk-otel-collector | grep "Body: Str(test logs pipeline)"'
161+
register: result
162+
changed_when: false
163+
until: result.stdout
164+
retries: 20
165+
delay: 1
166+
when: fluentd_supported
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
- name: Converge scenario with custom variables and v0.97.0 of Splunk Otel Collector
3+
hosts: all
4+
become: no
5+
vars:
6+
splunk_access_token: fake-token
7+
splunk_ingest_url: https://fake-splunk-ingest.com
8+
splunk_api_url: https://fake-splunk-api.com
9+
splunk_hec_url: https://fake-splunk-hec.com
10+
splunk_hec_token: fake-hec-token
11+
splunk_otel_collector_version: 0.97.0
12+
splunk_otel_collector_config: '{{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\custom_config.yml'
13+
splunk_otel_collector_config_source: ./custom_collector_config.yml
14+
splunk_memory_total_mib: 256
15+
gomemlimit: 230
16+
install_fluentd: yes
17+
splunk_listen_interface: 1.2.3.4
18+
splunk_fluentd_config: '{{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\custom_config.conf'
19+
splunk_fluentd_config_source: ./custom_fluentd_config.conf
20+
splunk_otel_collector_additional_env_vars:
21+
MY_CUSTOM_VAR1: value1
22+
MY_CUSTOM_VAR2: value2
23+
MY_CUSTOM_VAR3: 'value3 with spaces'
24+
install_splunk_dotnet_auto_instrumentation: true
25+
splunk_dotnet_auto_instrumentation_version: 1.8.0
26+
splunk_dotnet_auto_instrumentation_system_wide: true
27+
splunk_dotnet_auto_instrumentation_environment: test-environment
28+
splunk_dotnet_auto_instrumentation_service_name: test-service-name
29+
splunk_dotnet_auto_instrumentation_enable_profiler: true
30+
splunk_dotnet_auto_instrumentation_enable_profiler_memory: true
31+
splunk_dotnet_auto_instrumentation_additional_options:
32+
SPLUNK_DOTNET_VAR1: dotnet-value1
33+
SPLUNK_DOTNET_VAR2: dotnet-value2
34+
splunk_otel_auto_instrumentation_resource_attributes: dotnet-tag=dotnet-tag-value
35+
tasks:
36+
- name: "Include signalfx.splunk_otel_collector.collector role"
37+
include_role:
38+
name: "signalfx.splunk_otel_collector.collector"

0 commit comments

Comments
 (0)