Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Nov 7, 2023
1 parent a9f9d94 commit 9b699b7
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'deployments/ansible/galaxy.yml'
branches:
- main
- ansible-new-zeroconfig
pull_request:
paths:
- '.github/workflows/ansible.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Converge scenario with auto-instrumentation installation
hosts: all
become: yes
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
install_splunk_otel_auto_instrumentation: true
splunk_otel_auto_instrumentation_resource_attributes: deployment.environment=test
splunk_otel_auto_instrumentation_service_name: test
splunk_otel_auto_instrumentation_enable_profiler: true
splunk_otel_auto_instrumentation_enable_profiler_memory: true
splunk_otel_auto_instrumentation_enable_metrics: true
splunk_otel_auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no default config provided, make sure to set --base-config molecule argument instead
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
- name: Verify scenario with auto-instrumentation installation
hosts: all
gather_facts: false
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Assert splunk-otel-collector service is running
assert:
that: ansible_facts.services['splunk-otel-collector.service'].state == 'running'

- name: Populate package facts
ansible.builtin.package_facts:

- name: Get splunk-otel-auto-instrumentation version
set_fact:
auto_instrumentation_version: "{{ ansible_facts.packages['splunk-otel-auto-instrumentation'][0].version }}"

- name: Check for systemd drop-in file
ansible.builtin.stat:
path: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
register: systemd

- name: Assert systemd drop-in file does not exist
assert:
that: not systemd.stat.exists

- name: Assert /etc/ld.so.preload contains path to libsplunk.so
ansible.builtin.lineinfile:
line: /usr/lib/splunk-instrumentation/libsplunk.so
dest: /etc/ld.so.preload
state: present
check_mode: yes

- name: Assert instrumentation config contains path to java agent
ansible.builtin.lineinfile:
line: JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_RESOURCE_ATTRIBUTES
ansible.builtin.lineinfile:
line: "OTEL_RESOURCE_ATTRIBUTES=\
splunk.zc.method=splunk-otel-auto-instrumentation-{{ auto_instrumentation_version }},\
deployment.environment=test"
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_SERVICE_NAME
ansible.builtin.lineinfile:
line: OTEL_SERVICE_NAME=test
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_PROFILER_ENABLED=true
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_MEMORY_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_PROFILER_MEMORY_ENABLED=true
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_METRICS_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_METRICS_ENABLED=true
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_EXPORTER_OTLP_ENDPOINT
ansible.builtin.lineinfile:
line: OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4317
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Converge scenario with auto-instrumentation installation
hosts: all
become: yes
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
install_splunk_otel_auto_instrumentation: true
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no default config provided, make sure to set --base-config molecule argument instead
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
- name: Verify scenario with auto-instrumentation installation
hosts: all
gather_facts: false
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Assert splunk-otel-collector service is running
assert:
that: ansible_facts.services['splunk-otel-collector.service'].state == 'running'

- name: Populate package facts
ansible.builtin.package_facts:

- name: Get splunk-otel-auto-instrumentation version
set_fact:
auto_instrumentation_version: "{{ ansible_facts.packages['splunk-otel-auto-instrumentation'][0].version }}"

- name: Check for systemd drop-in file
ansible.builtin.stat:
path: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
register: systemd

- name: Assert systemd drop-in file does not exist
assert:
that: not systemd.stat.exists

- name: Assert /etc/ld.so.preload contains path to libsplunk.so
ansible.builtin.lineinfile:
line: /usr/lib/splunk-instrumentation/libsplunk.so
dest: /etc/ld.so.preload
state: present
check_mode: yes

- name: Assert instrumentation config contains path to java agent
ansible.builtin.lineinfile:
line: JAVA_TOOL_OPTIONS=-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_RESOURCE_ATTRIBUTES
ansible.builtin.lineinfile:
line: "OTEL_RESOURCE_ATTRIBUTES=\
splunk.zc.method=splunk-otel-auto-instrumentation-{{ auto_instrumentation_version }}"
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config does not contain OTEL_SERVICE_NAME
ansible.builtin.lineinfile:
regexp: '.*OTEL_SERVICE_NAME.*'
dest: /etc/splunk/zeroconfig/java.conf
state: absent
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_PROFILER_ENABLED=false
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_MEMORY_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_PROFILER_MEMORY_ENABLED=false
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_METRICS_ENABLED
ansible.builtin.lineinfile:
line: SPLUNK_METRICS_ENABLED=false
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_EXPORTER_OTLP_ENDPOINT
ansible.builtin.lineinfile:
line: OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317
dest: /etc/splunk/zeroconfig/java.conf
state: present
check_mode: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Converge scenario with auto-instrumentation installation
hosts: all
become: yes
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
install_splunk_otel_auto_instrumentation: true
splunk_otel_auto_instrumentation_systemd: true
splunk_otel_auto_instrumentation_resource_attributes: deployment.environment=test
splunk_otel_auto_instrumentation_service_name: test
splunk_otel_auto_instrumentation_enable_profiler: true
splunk_otel_auto_instrumentation_enable_profiler_memory: true
splunk_otel_auto_instrumentation_enable_metrics: true
splunk_otel_auto_instrumentation_otlp_endpoint: http://0.0.0.0:4317
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no default config provided, make sure to set --base-config molecule argument instead
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
- name: Verify scenario with auto-instrumentation installation
hosts: all
gather_facts: false
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Assert splunk-otel-collector service is running
assert:
that: ansible_facts.services['splunk-otel-collector.service'].state == 'running'

- name: Populate package facts
ansible.builtin.package_facts:

- name: Get splunk-otel-auto-instrumentation version
set_fact:
auto_instrumentation_version: "{{ ansible_facts.packages['splunk-otel-auto-instrumentation'][0].version }}"

- name: Check for /etc/ld.so.preload
ansible.builtin.stat:
path: /etc/ld.so.preload
register: preload

- name: Assert /etc/ld.so.preload does not exist
assert:
that: not preload.stat.exists

- name: Assert instrumentation config contains path to java agent
ansible.builtin.lineinfile:
line: "DefaultEnvironment=\"JAVA_TOOL_OPTIONS=\
-javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar\""
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_RESOURCE_ATTRIBUTES
ansible.builtin.lineinfile:
line: "DefaultEnvironment=\"OTEL_RESOURCE_ATTRIBUTES=\
splunk.zc.method=splunk-otel-auto-instrumentation-{{ auto_instrumentation_version }},\
deployment.environment=test\""
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_SERVICE_NAME
ansible.builtin.lineinfile:
line: DefaultEnvironment="OTEL_SERVICE_NAME=test"
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_ENABLED
ansible.builtin.lineinfile:
line: DefaultEnvironment="SPLUNK_PROFILER_ENABLED=true"
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_PROFILER_MEMORY_ENABLED
ansible.builtin.lineinfile:
line: DefaultEnvironment="SPLUNK_PROFILER_MEMORY_ENABLED=true"
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains SPLUNK_METRICS_ENABLED
ansible.builtin.lineinfile:
line: DefaultEnvironment="SPLUNK_METRICS_ENABLED=true"
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes

- name: Assert instrumentation config contains OTEL_EXPORTER_OTLP_ENDPOINT
ansible.builtin.lineinfile:
line: DefaultEnvironment="OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4317"
dest: /usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf
state: present
check_mode: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Converge scenario with auto-instrumentation installation
hosts: all
become: yes
vars:
splunk_access_token: fake-token
splunk_realm: fake-realm
install_splunk_otel_auto_instrumentation: true
splunk_otel_auto_instrumentation_systemd: true
tasks:
- name: "Include signalfx.splunk_otel_collector.collector role"
include_role:
name: "collector"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no default config provided, make sure to set --base-config molecule argument instead
Loading

0 comments on commit 9b699b7

Please sign in to comment.