Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible: Support new zero config #3901

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 19 additions & 0 deletions deployments/ansible/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## 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 (default: `http://127.0.0.1:4317`). Only
applicable if `splunk_otel_auto_instrumentation_version` is `latest` or >= `0.87.0`.

### 🧰 Bug fixes 🧰

- Ensure loop variables for Windows tasks are defined

## 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,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_ld_so_preload: "# my custom library"
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,110 @@
---
- 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 /etc/ld.so.preload contains custom line
ansible.builtin.lineinfile:
line: '# my custom library'
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