On this page
community.general.elastic – Create distributed traces for each Ansible task in Elastic APM
Note
This plugin is part of the community.general collection (version 3.8.1).
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.
To use it in a playbook, specify: community.general.elastic.
New in version 3.8.0: of community.general
Synopsis
- This callback creates distributed traces for each Ansible task in Elastic APM.
 - You can configure the plugin with environment variables.
 - See https://www.elastic.co/guide/en/apm/agent/python/current/configuration.html.
 
Requirements
The below requirements are needed on the local controller node that executes this callback.
- elastic-apm (Python library)
 
Parameters
| Parameter | Choices/Defaults | Configuration | Comments | 
|---|---|---|---|
| apm_api_key
        
        string
         | 
      
        
        env:ELASTIC_APM_API_KEY
         | 
      
        
        Use the APM API key
         | 
     |
| apm_secret_token
        
        string
         | 
      
        
        env:ELASTIC_APM_SECRET_TOKEN
         | 
      
        
        Use the APM server token
         | 
     |
| apm_server_url
        
        string
         | 
      
        
        env:ELASTIC_APM_SERVER_URL
         | 
      
        
        Use the APM server and its environment variables.
         | 
     |
| apm_service_name
        
        string
         | 
      Default: 
        "ansible"
         | 
      
        
        env:ELASTIC_APM_SERVICE_NAME
         | 
      
        
        The service name resource attribute.
         | 
     
| apm_verify_server_cert
        
        boolean
         | 
      
       
  | 
      
        
        env:ELASTIC_APM_VERIFY_SERVER_CERT
         | 
      
        
        Verifies the SSL certificate if an HTTPS connection.
         | 
     
| hide_task_arguments
        
        boolean
         | 
      
       
  | 
      
        
        env:ANSIBLE_OPENTELEMETRY_HIDE_TASK_ARGUMENTS
         | 
      
        
        Hide the arguments for a task.
         | 
     
| traceparent
        
        string
         | 
      
        
        env:TRACEPARENT
         | 
      
Examples
examples: |
  Enable the plugin in ansible.cfg:
    [defaults]
    callbacks_enabled = community.general.elastic
  Set the environment variable:
    export ELASTIC_APM_SERVER_URL=<your APM server URL)>
    export ELASTIC_APM_SERVICE_NAME=your_service_name
    export ELASTIC_APM_API_KEY=your_APM_API_KEY
  Authors
- Victor Martinez (@v1v) <VictorMartinezRubio@gmail.com>
 
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/latest/collections/community/general/elastic_callback.html