Skip to content

Commit f4530df

Browse files
test
1 parent c0b2a2b commit f4530df

File tree

24 files changed

+331
-191
lines changed

24 files changed

+331
-191
lines changed

.github/workflows/ansible.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- 'deployments/ansible/galaxy.yml'
1313
branches:
1414
- main
15+
- ansible-discovery-mode
1516
pull_request:
1617
paths:
1718
- '.github/workflows/ansible.yml'
@@ -140,7 +141,7 @@ jobs:
140141
scenario:
141142
- default
142143
- custom_vars
143-
- with_instrumentation
144+
- with_signalfx_dotnet_instrumentation
144145
steps:
145146
- name: Free up disk space for vagrant box
146147
uses: jlumbroso/[email protected]
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ansible~=7.0
2-
ansible-lint==5.4.0
3-
molecule==3.3.0
4-
molecule-docker==0.2.4
5-
docker==5.0.0
6-
urllib3>=1.26.18,<2
1+
ansible~=8.7.0
2+
ansible-lint==6.22.2
3+
molecule==6.0.3
4+
molecule-plugins[docker]==23.5.0
5+
docker==7.0.0
6+
urllib3<2
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: Converge scenario with custom variables
3+
hosts: all
4+
become: yes
5+
vars:
6+
splunk_access_token: fake-token
7+
splunk_realm: fake-realm
8+
splunk_otel_auto_discovery: yes
9+
splunk_otel_auto_discovery_properties_source: ./test.discovery.yaml
10+
splunk_otel_auto_discovery_properties_dest: /foo/bar/test.discovery.yaml
11+
splunk_otel_collector_additional_env_vars:
12+
OTELCOL_OPTIONS: "--set=processors.batch.timeout=2s"
13+
tasks:
14+
- name: "Include signalfx.splunk_otel_collector.collector role"
15+
include_role:
16+
name: "signalfx.splunk_otel_collector.collector"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# my custom discovery properties file
2+
---
3+
splunk.discovery:
4+
extensions:
5+
k8s_observer:
6+
enabled: false
7+
docker_observer:
8+
enabled: false
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
- name: Verify scenario with custom variables
3+
hosts: all
4+
gather_facts: true
5+
become: yes
6+
tasks:
7+
- name: Populate service facts
8+
ansible.builtin.service_facts:
9+
10+
- name: Assert splunk-otel-collector service is running
11+
assert:
12+
that: ansible_facts.services['splunk-otel-collector.service'].state == 'running'
13+
14+
- name: Assert SPLUNK_ACCESS_TOKEN env var is set
15+
ansible.builtin.lineinfile:
16+
line: SPLUNK_ACCESS_TOKEN=fake-token
17+
dest: /etc/otel/collector/splunk-otel-collector.conf
18+
state: present
19+
check_mode: yes
20+
register: config
21+
failed_when: config is changed
22+
23+
- name: Assert SPLUNK_REALM env var is set
24+
ansible.builtin.lineinfile:
25+
line: SPLUNK_REALM=fake-realm
26+
dest: /etc/otel/collector/splunk-otel-collector.conf
27+
state: present
28+
check_mode: yes
29+
register: config
30+
failed_when: config is changed
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+
register: config
39+
failed_when: config is changed
40+
41+
- name: Assert SPLUNK_API_URL env var is set
42+
ansible.builtin.lineinfile:
43+
line: SPLUNK_API_URL=https://api.fake-realm.signalfx.com
44+
dest: /etc/otel/collector/splunk-otel-collector.conf
45+
state: present
46+
check_mode: yes
47+
register: config
48+
failed_when: config is changed
49+
50+
- name: Assert SPLUNK_TRACE_URL env var is set
51+
ansible.builtin.lineinfile:
52+
line: SPLUNK_TRACE_URL=https://ingest.fake-realm.signalfx.com/v2/trace
53+
dest: /etc/otel/collector/splunk-otel-collector.conf
54+
state: present
55+
check_mode: yes
56+
register: config
57+
failed_when: config is changed
58+
59+
- name: Assert SPLUNK_HEC_URL env var is set
60+
ansible.builtin.lineinfile:
61+
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
62+
dest: /etc/otel/collector/splunk-otel-collector.conf
63+
state: present
64+
check_mode: yes
65+
register: config
66+
failed_when: config is changed
67+
68+
- name: Assert discovery mode is enabled
69+
ansible.builtin.lineinfile:
70+
line: >-
71+
OTELCOL_OPTIONS=--set=processors.batch.timeout=2s --discovery
72+
--discovery-properties=/foo/bar/test.discovery.yaml
73+
dest: /etc/otel/collector/splunk-otel-collector.conf
74+
state: present
75+
check_mode: yes
76+
register: config
77+
failed_when: config is changed
78+
79+
- name: Assert custom properties file is created
80+
ansible.builtin.lineinfile:
81+
line: '# my custom discovery properties file'
82+
dest: /foo/bar/test.discovery.yaml
83+
state: present
84+
check_mode: yes
85+
register: config
86+
failed_when: config is changed
87+
88+
- name: Check collector logs
89+
ansible.builtin.shell:
90+
cmd: 'journalctl -u splunk-otel-collector | grep "Discovery complete"'
91+
register: result
92+
changed_when: false
93+
until: result.stdout
94+
retries: 20
95+
delay: 1

deployments/ansible/molecule/custom_vars/verify.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,62 @@
2222
dest: /etc/otel/collector/splunk-otel-collector.conf
2323
state: present
2424
check_mode: yes
25+
register: config
26+
failed_when: config is changed
2527

2628
- name: Assert SPLUNK_INGEST_URL env var is set
2729
ansible.builtin.lineinfile:
2830
line: SPLUNK_INGEST_URL=https://fake-splunk-ingest.com
2931
dest: /etc/otel/collector/splunk-otel-collector.conf
3032
state: present
3133
check_mode: yes
34+
register: config
35+
failed_when: config is changed
3236

3337
- name: Assert SPLUNK_API_URL env var is set
3438
ansible.builtin.lineinfile:
3539
line: SPLUNK_API_URL=https://fake-splunk-api.com
3640
dest: /etc/otel/collector/splunk-otel-collector.conf
3741
state: present
3842
check_mode: yes
43+
register: config
44+
failed_when: config is changed
3945

4046
- name: Assert SPLUNK_TRACE_URL env var is set
4147
ansible.builtin.lineinfile:
4248
line: SPLUNK_TRACE_URL=https://fake-splunk-ingest.com/v2/trace
4349
dest: /etc/otel/collector/splunk-otel-collector.conf
4450
state: present
4551
check_mode: yes
52+
register: config
53+
failed_when: config is changed
4654

4755
- name: Assert SPLUNK_HEC_URL env var is set
4856
ansible.builtin.lineinfile:
4957
line: SPLUNK_HEC_URL=https://fake-splunk-ingest.com/v1/log
5058
dest: /etc/otel/collector/splunk-otel-collector.conf
5159
state: present
5260
check_mode: yes
61+
register: config
62+
failed_when: config is changed
5363

5464
- name: Assert MY_CUSTOM_VAR1 env var is set
5565
ansible.builtin.lineinfile:
5666
line: MY_CUSTOM_VAR1=value1
5767
dest: /etc/otel/collector/splunk-otel-collector.conf
5868
state: present
5969
check_mode: yes
70+
register: config
71+
failed_when: config is changed
6072

6173
- name: Assert MY_CUSTOM_VAR2 env var is set
6274
ansible.builtin.lineinfile:
6375
line: MY_CUSTOM_VAR2=value2
6476
dest: /etc/otel/collector/splunk-otel-collector.conf
6577
state: present
6678
check_mode: yes
79+
register: config
80+
failed_when: config is changed
6781

6882
- name: Populate package facts
6983
ansible.builtin.package_facts:
@@ -78,34 +92,44 @@
7892
dest: /etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf
7993
state: present
8094
check_mode: yes
95+
register: config
96+
failed_when: config is changed
8197

8298
- name: Assert custom service group is set
8399
ansible.builtin.lineinfile:
84100
line: Group=custom-group
85101
dest: /etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf
86102
state: present
87103
check_mode: yes
104+
register: config
105+
failed_when: config is changed
88106

89107
- name: Assert SPLUNK_MEMORY_TOTAL_MIB env var is set
90108
ansible.builtin.lineinfile:
91109
line: SPLUNK_MEMORY_TOTAL_MIB=256
92110
dest: /etc/otel/collector/splunk-otel-collector.conf
93111
state: present
94112
check_mode: yes
113+
register: config
114+
failed_when: config is changed
95115

96116
- name: Assert SPLUNK_LISTEN_INTERFACE env var is set
97117
ansible.builtin.lineinfile:
98118
line: SPLUNK_LISTEN_INTERFACE=1.2.3.4
99119
dest: /etc/otel/collector/splunk-otel-collector.conf
100120
state: present
101121
check_mode: yes
122+
register: config
123+
failed_when: config is changed
102124

103125
- name: Assert GOMEMLIMIT env var is set
104126
ansible.builtin.lineinfile:
105127
line: GOMEMLIMIT=230
106128
dest: /etc/otel/collector/splunk-otel-collector.conf
107129
state: present
108130
check_mode: yes
131+
register: config
132+
failed_when: config is changed
109133

110134
- name: Check custom_fluentd.conf
111135
stat:
@@ -124,6 +148,8 @@
124148
state: present
125149
check_mode: yes
126150
when: fluentd_supported
151+
register: config
152+
failed_when: config is changed
127153

128154
- name: Send a test log message
129155
ansible.builtin.uri:

deployments/ansible/molecule/default/verify.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,59 @@
2121
dest: /etc/otel/collector/splunk-otel-collector.conf
2222
state: present
2323
check_mode: yes
24+
register: config
25+
failed_when: config is changed
2426

2527
- name: Assert SPLUNK_REALM env var is set
2628
ansible.builtin.lineinfile:
2729
line: SPLUNK_REALM=fake-realm
2830
dest: /etc/otel/collector/splunk-otel-collector.conf
2931
state: present
3032
check_mode: yes
33+
register: config
34+
failed_when: config is changed
3135

3236
- name: Assert SPLUNK_INGEST_URL env var is set
3337
ansible.builtin.lineinfile:
3438
line: SPLUNK_INGEST_URL=https://ingest.fake-realm.signalfx.com
3539
dest: /etc/otel/collector/splunk-otel-collector.conf
3640
state: present
3741
check_mode: yes
42+
register: config
43+
failed_when: config is changed
3844

3945
- name: Assert SPLUNK_API_URL env var is set
4046
ansible.builtin.lineinfile:
41-
line: SPLUNK_INGEST_URL=https://api.fake-realm.signalfx.com
47+
line: SPLUNK_API_URL=https://api.fake-realm.signalfx.com
4248
dest: /etc/otel/collector/splunk-otel-collector.conf
4349
state: present
4450
check_mode: yes
51+
register: config
52+
failed_when: config is changed
4553

4654
- name: Assert SPLUNK_TRACE_URL env var is set
4755
ansible.builtin.lineinfile:
4856
line: SPLUNK_TRACE_URL=https://ingest.fake-realm.signalfx.com/v2/trace
4957
dest: /etc/otel/collector/splunk-otel-collector.conf
5058
state: present
5159
check_mode: yes
60+
register: config
61+
failed_when: config is changed
5262

5363
- name: Assert SPLUNK_HEC_URL env var is set
5464
ansible.builtin.lineinfile:
5565
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
5666
dest: /etc/otel/collector/splunk-otel-collector.conf
5767
state: present
5868
check_mode: yes
69+
register: config
70+
failed_when: config is changed
71+
72+
- name: Assert discovery mode is not enabled
73+
ansible.builtin.lineinfile:
74+
regexp: .*OTELCOL_OPTIONS=.*--discovery.*
75+
dest: /etc/otel/collector/splunk-otel-collector.conf
76+
state: absent
77+
check_mode: yes
78+
register: config
79+
failed_when: config is changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/Dockerfile.j2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Converge scenario with custom variables
3+
hosts: all
4+
become: yes
5+
vars:
6+
splunk_access_token: fake-token
7+
splunk_realm: fake-realm
8+
splunk_otel_auto_discovery: yes
9+
tasks:
10+
- name: "Include signalfx.splunk_otel_collector.collector role"
11+
include_role:
12+
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

0 commit comments

Comments
 (0)