community.general.opentelemetry callback – Create distributed traces with OpenTelemetry

Note

This callback plugin is part of the community.general collection (version 8.6.7).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this callback plugin, see Requirements for details.

To use it in a playbook, specify: community.general.opentelemetry.

New in community.general 3.7.0

Callback plugin

This plugin is a notification callback. It sends information for a playbook run to other applications, services, or systems. See Callback plugins for more information on callback plugins.

Synopsis

Requirements

The below requirements are needed on the local controller node that executes this callback.

  • opentelemetry-api (Python library)

  • opentelemetry-exporter-otlp (Python library)

  • opentelemetry-sdk (Python library)

Parameters

Parameter

Comments

disable_attributes_in_logs

boolean

added in community.general 7.1.0

Disable populating span attributes to the logs.

Choices:

  • false ← (default)

  • true

Configuration:

disable_logs

boolean

added in community.general 5.8.0

Disable sending logs.

Choices:

  • false ← (default)

  • true

Configuration:

enable_from_environment

string

added in community.general 3.8.0

Whether to enable this callback only if the given environment variable exists and it is set to true.

This is handy when you use Configuration as Code and want to send distributed traces if running in the CI rather when running Ansible locally.

For such, it evaluates the given enable_from_environment value as environment variable and if set to true this plugin will be enabled.

Configuration:

hide_task_arguments

boolean

Hide the arguments for a task.

Choices:

  • false ← (default)

  • true

Configuration:

otel_service_name

string

The service name resource attribute.

Default: "ansible"

Configuration:

  • INI entry:

    [callback_opentelemetry]
    otel_service_name = ansible
    

    added in community.general 5.3.0

  • Environment variable: OTEL_SERVICE_NAME

traceparent

string

The W3C Trace Context header traceparent.

Default: "None"

Configuration:

Examples

examples: |
  Enable the plugin in ansible.cfg:
    [defaults]
    callbacks_enabled = community.general.opentelemetry
    [callback_opentelemetry]
    enable_from_environment = ANSIBLE_OPENTELEMETRY_ENABLED

  Set the environment variable:
    export OTEL_EXPORTER_OTLP_ENDPOINT=<your endpoint (OTLP/HTTP)>
    export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer your_otel_token"
    export OTEL_SERVICE_NAME=your_service_name
    export ANSIBLE_OPENTELEMETRY_ENABLED=true

Authors

  • Victor Martinez (@v1v)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.