Skip to content

Commit ac9bcf8

Browse files
authored
[ansible] Fix incorrect environmental variable naming (#6303)
* [chore][ansible] Update tests to confirm variables are set * update version tag, fix naming difference * fix test to check for right variable * Update deployments/ansible/galaxy.yml
1 parent be1bce1 commit ac9bcf8

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

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_HEC_URL env var is set
4147
ansible.builtin.lineinfile:
4248
line: SPLUNK_HEC_URL=https://fake-splunk-ingest.com/v1/log
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 OTELCOL_OPTIONS env var is set per splunk_otel_collector_command_line_args
4856
ansible.builtin.lineinfile:
4957
line: OTELCOL_OPTIONS=--discovery
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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,41 @@
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_HEC_URL env var is set
4755
ansible.builtin.lineinfile:
4856
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
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

deployments/ansible/roles/collector/templates/splunk-otel-collector.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OTELCOL_CONFIG={{ splunk_otel_collector_command_line_args }}
1+
OTELCOL_OPTIONS={{ splunk_otel_collector_command_line_args }}
22
SPLUNK_CONFIG={{ splunk_otel_collector_config }}
33
SPLUNK_ACCESS_TOKEN={{ splunk_access_token }}
44
SPLUNK_REALM={{ splunk_realm }}

0 commit comments

Comments
 (0)