Skip to content

Commit 2b49278

Browse files
test
1 parent f759935 commit 2b49278

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
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'

deployments/ansible/molecule/custom_vars/converge.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
splunk_access_token: fake-token
77
splunk_ingest_url: https://fake-splunk-ingest.com
88
splunk_api_url: https://fake-splunk-api.com
9-
splunk_otel_collector_version: 0.48.0
9+
splunk_otel_collector_version: 0.81.0
1010
splunk_otel_collector_config: /etc/otel/collector/custom_config.yml
1111
splunk_otel_collector_config_source: ./custom_collector_config.yml
1212
splunk_service_user: custom-user
@@ -20,6 +20,10 @@
2020
splunk_otel_collector_additional_env_vars:
2121
MY_CUSTOM_VAR1: value1
2222
MY_CUSTOM_VAR2: value2
23+
splunk_discovery_mode: yes
24+
splunk_discovery_properties_yaml: |
25+
splunk.discovery.extensions.host_observer.enabled: true
26+
splunk_discovery_properties_dest: /tmp/test.properties.yaml
2327
tasks:
2428
- name: "Include signalfx.splunk_otel_collector.collector role"
2529
include_role:

deployments/ansible/molecule/custom_vars/verify.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@
6565
state: present
6666
check_mode: yes
6767

68+
- name: Assert discovery mode is enabled
69+
ansible.builtin.lineinfile:
70+
line: OTELCOL_OPTIONS=--discovery --discovery-properties=/tmp/test.properties.yaml
71+
dest: /etc/otel/collector/splunk-otel-collector.conf
72+
state: present
73+
check_mode: yes
74+
75+
- name: Assert discovery properties file
76+
ansible.builtin.lineinfile:
77+
line: "splunk.discovery.extensions.host_observer.enabled: true"
78+
dest: /tmp/test.properties.yaml
79+
state: present
80+
check_mode: yes
81+
6882
- name: Populate package facts
6983
ansible.builtin.package_facts:
7084

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+
line: OTELCOL_OPTIONS=--discovery
63+
dest: /etc/otel/collector/splunk-otel-collector.conf
64+
state: absent
65+
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 | to_nice_yaml (indent=2) }}"
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ 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+
OTELCOL_OPTIONS=--discovery --discovery-properties={{ splunk_discovery_properties_dest }}
37+
{% endif %}

0 commit comments

Comments
 (0)