Skip to content

Commit cfd0c8a

Browse files
test
1 parent c00277e commit cfd0c8a

File tree

13 files changed

+196
-0
lines changed

13 files changed

+196
-0
lines changed

.github/workflows/ansible.yml

Lines changed: 1 addition & 0 deletions
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'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/Dockerfile.j2
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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_discovery_mode: yes
9+
splunk_discovery_properties_yaml: |
10+
# my custom discovery properties file
11+
---
12+
splunk.discovery:
13+
extensions:
14+
k8s_observer:
15+
enabled: false
16+
docker_observer:
17+
enabled: false
18+
splunk_discovery_properties_dest: /tmp/test.discovery.yaml
19+
tasks:
20+
- name: "Include signalfx.splunk_otel_collector.collector role"
21+
include_role:
22+
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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
21+
- name: Assert SPLUNK_REALM env var is set
22+
ansible.builtin.lineinfile:
23+
line: SPLUNK_REALM=fake-realm
24+
dest: /etc/otel/collector/splunk-otel-collector.conf
25+
state: present
26+
check_mode: yes
27+
28+
- name: Assert SPLUNK_INGEST_URL env var is set
29+
ansible.builtin.lineinfile:
30+
line: SPLUNK_INGEST_URL=https://ingest.fake-realm.signalfx.com
31+
dest: /etc/otel/collector/splunk-otel-collector.conf
32+
state: present
33+
check_mode: yes
34+
35+
- name: Assert SPLUNK_API_URL env var is set
36+
ansible.builtin.lineinfile:
37+
line: SPLUNK_INGEST_URL=https://api.fake-realm.signalfx.com
38+
dest: /etc/otel/collector/splunk-otel-collector.conf
39+
state: present
40+
check_mode: yes
41+
42+
- name: Assert SPLUNK_TRACE_URL env var is set
43+
ansible.builtin.lineinfile:
44+
line: SPLUNK_TRACE_URL=https://ingest.fake-realm.signalfx.com/v2/trace
45+
dest: /etc/otel/collector/splunk-otel-collector.conf
46+
state: present
47+
check_mode: yes
48+
49+
- name: Assert SPLUNK_HEC_URL env var is set
50+
ansible.builtin.lineinfile:
51+
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
52+
dest: /etc/otel/collector/splunk-otel-collector.conf
53+
state: present
54+
check_mode: yes
55+
56+
- name: Assert discovery mode is enabled
57+
ansible.builtin.lineinfile:
58+
line: OTELCOL_OPTIONS=--discovery --discovery-properties=/tmp/test.discovery.yaml
59+
dest: /etc/otel/collector/splunk-otel-collector.conf
60+
state: present
61+
check_mode: yes
62+
63+
- name: Assert custom properties file is created
64+
ansible.builtin.lineinfile:
65+
line: '# my custom discovery properties file'
66+
dest: /tmp/test.discovery.yaml
67+
state: present
68+
check_mode: yes

deployments/ansible/molecule/default/verify.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@
5656
dest: /etc/otel/collector/splunk-otel-collector.conf
5757
state: present
5858
check_mode: yes
59+
60+
- name: Assert discovery mode is not enabled
61+
ansible.builtin.lineinfile:
62+
regexp: .*OTELCOL_OPTIONS=.*--discovery.*
63+
dest: /etc/otel/collector/splunk-otel-collector.conf
64+
state: absent
65+
check_mode: yes
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_discovery_mode: 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
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
21+
- name: Assert SPLUNK_REALM env var is set
22+
ansible.builtin.lineinfile:
23+
line: SPLUNK_REALM=fake-realm
24+
dest: /etc/otel/collector/splunk-otel-collector.conf
25+
state: present
26+
check_mode: yes
27+
28+
- name: Assert SPLUNK_INGEST_URL env var is set
29+
ansible.builtin.lineinfile:
30+
line: SPLUNK_INGEST_URL=https://ingest.fake-realm.signalfx.com
31+
dest: /etc/otel/collector/splunk-otel-collector.conf
32+
state: present
33+
check_mode: yes
34+
35+
- name: Assert SPLUNK_API_URL env var is set
36+
ansible.builtin.lineinfile:
37+
line: SPLUNK_INGEST_URL=https://api.fake-realm.signalfx.com
38+
dest: /etc/otel/collector/splunk-otel-collector.conf
39+
state: present
40+
check_mode: yes
41+
42+
- name: Assert SPLUNK_TRACE_URL env var is set
43+
ansible.builtin.lineinfile:
44+
line: SPLUNK_TRACE_URL=https://ingest.fake-realm.signalfx.com/v2/trace
45+
dest: /etc/otel/collector/splunk-otel-collector.conf
46+
state: present
47+
check_mode: yes
48+
49+
- name: Assert SPLUNK_HEC_URL env var is set
50+
ansible.builtin.lineinfile:
51+
line: SPLUNK_HEC_URL=https://ingest.fake-realm.signalfx.com/v1/log
52+
dest: /etc/otel/collector/splunk-otel-collector.conf
53+
state: present
54+
check_mode: yes
55+
56+
- name: Assert discovery mode is enabled
57+
ansible.builtin.lineinfile:
58+
line: OTELCOL_OPTIONS=--discovery
59+
dest: /etc/otel/collector/splunk-otel-collector.conf
60+
state: present
61+
check_mode: yes

deployments/ansible/roles/collector/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ signalfx_dotnet_auto_instrumentation_enable_profiler_memory: false
9696
signalfx_dotnet_auto_instrumentation_global_tags: ""
9797
signalfx_dotnet_auto_instrumentation_iisreset: true
9898
signalfx_dotnet_auto_instrumentation_additional_options: {}
99+
100+
splunk_discovery_mode: false
101+
splunk_discovery_properties_yaml: ""
102+
splunk_discovery_properties_dest: /etc/otel/collector/config.d/properties.discovery.yaml

deployments/ansible/roles/collector/tasks/linux_install.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
when: splunk_otel_collector_config_source != ''
6464
notify: "restart splunk-otel-collector"
6565

66+
- name: Create the discovery properties file
67+
ansible.builtin.copy:
68+
content: "{{ splunk_discovery_properties_yaml }}"
69+
dest: "{{ splunk_discovery_properties_dest }}"
70+
owner: "{{ splunk_service_user }}"
71+
group: "{{ splunk_service_group }}"
72+
mode: 0644
73+
when: splunk_discovery_properties_yaml != ''
74+
notify: "restart splunk-otel-collector"
75+
6676
- name: Install FluentD
6777
ansible.builtin.import_tasks: linux_install_fluentd.yml
6878
when: install_fluentd and fluentd_supported

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ SPLUNK_COLLECTD_DIR={{ splunk_collectd_dir }}
3232
{{ key }}={{ value }}
3333
{% endfor %}
3434
{% endif %}
35+
{% if splunk_discovery_mode is defined and splunk_discovery_mode %}
36+
{% if splunk_discovery_properties_yaml is defined and splunk_discovery_properties_yaml %}
37+
OTELCOL_OPTIONS=--discovery --discovery-properties={{ splunk_discovery_properties_dest }}
38+
{% else %}
39+
OTELCOL_OPTIONS=--discovery
40+
{% endif %}
41+
{% endif %}

0 commit comments

Comments
 (0)