-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Summary
When executing multiple playbooks within a single ansible-playbook command (e.g., ansible-playbook first.yml second.yml), the OpenTelemetry trace context is not isolated per playbook. Instead, trace data from preceding playbooks accumulates and is incorrectly included in the traces of all subsequent playbooks.
Steps to Reproduce
-
Configure the opentelemetry callback in ansible.cfg to send data to an Elastic APM server.
-
Create two or more simple playbooks (e.g., first.yml, second.yml, third.yml).
-
Execute a single ansible-playbook command listing all playbooks sequentially:
ansible-playbook first.yml second.yml third.yml
- Observe the resulting traces in the Elastic APM UI.
Expected Behavior
Each playbook should generate its own distinct trace, containing only its own playbook name and tasks.
The trace for first.yml should contain only data from first.yml.
The trace for second.yml should contain only data from second.yml.
The trace for third.yml should contain only data from third.yml.
Actual Behavior
Trace data accumulates incorrectly:
first.yml: The trace appears correctly with its own data.
second.yml: The trace contains data from both first.yml and second.yml.
third.yml: The trace contains data from first.yml, second.yml, and third.yml.
Issue Type
Bug Report
Component Name
opentelemetry
Ansible Version
ansible [core 2.17.12]
config file = /home/user/ansible_repo/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.12/dist-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] (/usr/bin/python3)
jinja version = 3.1.6
libyaml = True
Community.general Version
# /home/user/.local/lib/python3.12/site-packages/ansible_collections
Collection Version
----------------- -------
community.general 9.3.0
# /usr/local/lib/python3.12/dist-packages/ansible_collections
Collection Version
----------------- -------
community.general 9.3.0
Configuration
CALLBACKS_ENABLED(/home/user/ansible_repo/ansible.cfg) = ['default', 'timer', 'community.general.opentelemetry']
CONFIG_FILE() = /home/user/ansible_repo/ansible.cfg
DEFAULT_CALLBACK_PLUGIN_PATH(/home/user/ansible_repo/ansible.cfg) = ['/home/user/ansible_repo/callback_plugins']
DEFAULT_FORKS(/home/user/ansible_repo/ansible.cfg) = 10
DEFAULT_LOG_PATH(/home/user/ansible_repo/ansible.cfg) = /home/user/ansible_repo/ansible.log
DEFAULT_TIMEOUT(/home/user/ansible_repo/ansible.cfg) = 60
HOST_KEY_CHECKING(/home/user/ansible_repo/ansible.cfg) = False
OS / Environment
Ubuntu 24
Steps to Reproduce
1. Configure the opentelemetry callback in ansible.cfg to send data to an Elastic APM server.
2. Create two or more simple playbooks (e.g., first.yml, second.yml, third.yml).
3. Execute a single ansible-playbook command listing all playbooks sequentiallyansible-playbook first.yml second.yml third.yml
4. Observe the resulting traces in the Elastic APM UI.
Expected Results
Each playbook should generate its own distinct trace, containing only its own playbook name and tasks.
-
The trace for first.yml should contain only data from first.yml.
-
The trace for second.yml should contain only data from second.yml.
-
The trace for third.yml should contain only data from third.yml.
Actual Results
Trace data accumulates incorrectly:
first.yml: The trace appears correctly with its own data.
second.yml: The trace contains data from both first.yml and second.yml.
third.yml: The trace contains data from first.yml, second.yml, and third.yml.Code of Conduct
- I agree to follow the Ansible Code of Conduct