Skip to content

Commit

Permalink
ansible: Support new zero config
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Nov 8, 2023
1 parent cb8e08e commit 8ed3f05
Show file tree
Hide file tree
Showing 26 changed files with 632 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.11'

- name: Install yamllint.
run: pip3 install yamllint
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.11'
cache: 'pip'
cache-dependency-path: "${{ github.workspace }}/requirements.txt"

Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.11'
cache: 'pip'
cache-dependency-path: "${{ github.workspace }}/requirements.txt"

Expand Down
15 changes: 15 additions & 0 deletions deployments/ansible/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## unreleased

## ansible-v0.24.0

### 🚩 Deprecations 🚩

- The `splunk_otel_auto_instrumentation_generate_service_name` and `splunk_otel_auto_instrumentation_disable_telemetry`
options are deprecated and only applicable if `splunk_otel_auto_instrumentation_version` is < `0.87.0`.

### 💡 Enhancements 💡

- Support Splunk OpenTelemetry Auto Instrumentation [v0.87.0](
https://github.com/signalfx/splunk-otel-collector/releases/tag/v0.87.0) and newer (Java only).
- Support activation and configuration of auto instrumentation for only `systemd` services.
- Support setting the OTLP exporter endpoint for auto instrumentation. Only applicable if
`splunk_otel_auto_instrumentation_version` is `latest` or >= `0.87.0`. (default: `http://127.0.0.1:4317`)

## ansible-v0.23.0

### 💡 Enhancements 💡
Expand Down
2 changes: 1 addition & 1 deletion deployments/ansible/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace: signalfx
name: splunk_otel_collector
description: Ansible collection for Splunk OpenTelemetry Collector
version: 0.23.0
version: 0.24.0
readme: README.md
authors:
- Splunk Inc.
Expand Down
18 changes: 18 additions & 0 deletions deployments/ansible/molecule/with_instrumentation/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,77 @@
dest: /etc/ld.so.preload
state: present
check_mode: yes
register: preload
failed_when: preload is changed

- name: Assert instrumentation config contains path to java agent
ansible.builtin.lineinfile:
line: java_agent_jar=/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains resource attribute
ansible.builtin.lineinfile:
line: resource_attributes=splunk.zc.method=splunk-otel-auto-instrumentation-0.50.0,deployment.environment=test
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains service name
ansible.builtin.lineinfile:
line: service_name=test
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains generate_service_name
ansible.builtin.lineinfile:
line: generate_service_name=false
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains disable_telemetry
ansible.builtin.lineinfile:
line: disable_telemetry=true
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains enable_profiler
ansible.builtin.lineinfile:
line: enable_profiler=true
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains enable_profiler_memory
ansible.builtin.lineinfile:
line: enable_profiler_memory=true
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed

- name: Assert instrumentation config contains enable_metrics
ansible.builtin.lineinfile:
line: enable_metrics=true
dest: /usr/lib/splunk-instrumentation/instrumentation.conf
state: present
check_mode: yes
register: config
failed_when: config is changed
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,101 @@
---
- 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
register: preload
failed_when: preload is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed
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,100 @@
---
- 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
register: preload
failed_when: preload is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed

- 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
register: config
failed_when: config is changed
Loading

0 comments on commit 8ed3f05

Please sign in to comment.