Red Hat Event-Driven Ansible

Preview

When you integrate your Dynatrace environment with Red Hat Event-Driven Ansible controller using Red Hat Ansible Connector Red Hat Ansible for Workflows, you can automatically send events to the Event-Driven Ansible Controller by using the dt_webhook event source plugin.

Configure the integration

To use Red Hat Ansible workflow actions, you first need to install Red Hat Ansible Connector Red Hat Ansible for Workflows from Dynatrace Hub.

  1. In Dynatrace Hub Hub, select Red Hat Ansible.
  2. Select Install and then follow the process below to set up your Event-Driven Ansible environment, grant permissions, and configure the connection.

Step 1 Configuration of Event-Driven Ansible controller

Prerequisites

The collection dynatrace.event_driven_ansible that contains dt_webhook must be installed on the Event-Driven Ansible Controller.

For more information on the Event-Driven Ansible Controller , see Event-Driven Ansible controller user guide.

Project configuration

For more information on how to configure a project, see Event-Driven Ansible controller user guide.

Setting up a decision environment

For more information on how to set up a new decision environment, see Event-Driven Ansible controller user guide.

Event source plugin and rulebook configuration

A rulebook activation is used to enable an event source. Hence, it is necessary to set up a rulebook.

The rulebook should be located in the configured project repository in the directory /rulebooks. For more information, see Event-Driven Ansible rulebook example.

The first part of the rulebook is the configuration of the event source (source plugin). The second part of the rulebook configuration contains the actual rules. A rule includes conditions and actions.

Example rulebook for dt_webhook

To use the dt_webhook plugin, you need to configure it as a source in your rulebook. The following arguments must be set.

  • host

    • This can be, for example, a localhost or 0.0.0.0.
  • port

    • Configure the port which will be used from the source plugin to listen for events.
    • Hints:
      • The API URL in Red Hat Event-Driven Ansible Connection has the same port as defined here.
      • Prerequisite for the port configuration.
  • token

    • Define a variable name for the token here, for example dt_webhook_token.
    • Hints:
      • This token variable will be set in the rulebook activation later on the Red Hat Event-Driven Ansible Controller.
      • dt_webhook_token is just an example name for the token variable. It could be also another name but the name must be the same in the rulebook activation and rulebook configuration.
    ---
    - name: Listen for events on dt_webhook
    hosts: all
    sources:
    - dynatrace.event_driven_ansible.dt_webhook:
    host: 0.0.0.0
    port: 5000
    token: '{{ dt_webhook_token }}'
    rules:
    - name: API Endpoint not available
    condition: event.payload.eventData["event.name"] is match ("Monitoring not available")
    action:
    run_job_template:
    name: "Trigger test playbook"
    organization: "Default"

When the rulebook configuration is done, ensure your project repository is synchronized to the Event-Driven Ansible Controller by selecting Sync project in the project list.

Sync projects

The next step then is to configure the rulebook activation. Select Rulebook Activations from the navigation panel on your Event-Driven Ansible Controller. Select Create rulebook activation and fill in the required fields.

In the field Variables you define the token by setting your token variable from the Rulebook configuration. The rulebook variables are in a JSON/YAML format.

Ensure the variable name is identical in the rulebook activation and rulebook configuration.

Configure a rulebook activation

For more information on configuring a rulebook activation on the Event-Driven Ansible controller, see Setting up a rulebook activation.

When the rulebook activation is enabled, events can be sent from the workflow action to the Event-Driven Ansible Controller.

Step 2 Grant permissions to Workflows

Some permissions are required by Workflows to run actions on your behalf.

To fine-tune permissions granted to Workflows

  1. Go to Workflows and select Settings > Authorization settings.
  2. Select the following permissions besides the general Workflows permission.
  • Permissions needed for workflow actions:
    • app-settings:objects:read
    • state:app-states:read
    • state:app-states:write
    • state:app-states:delete

For more on general Workflows user permissions, see User permissions for workflows.

Step 3 Configure Red Hat Ansible connection

You need a configured connection for your Red Hat Event-Driven Ansible environments.

This connection connects to the dt_webhook plugin within Red Hat Event-Driven Ansible. Open a specific port on your firewall to ensure the plugin is accessible for these connections. If this is impossible, you can use EdgeConnect to tunnel the traffic and make the environment accessible.

To configure a connection for the Red Hat Event-Driven Ansible Controller

  1. Go to Settings and select Connections > Connectors > Red Hat Ansible.
  2. Select the tab Event-Driven Ansible.
  3. Select Add Connection.
  4. Provide a meaningful name for your connection.
  5. Provide your Red Hat Event-Driven-Ansible Controller URL, for example, http://your-eda-controller.redhat.com:your-port (must include the port, which is configured in the Ansible Rulebook).
  6. Provide your token of the Red Hat Event-Driven Ansible source plugin.
  7. Select Create.

Available action

The following workflow action is available for the Red Hat Event-Driven Ansible controller.

Action

Description

Red Hat Ansible API endpoint

Send event to Event-Driven Ansible

Send an event to the Red Hat Event-Driven Ansible Controller via Event Source Plugin

POST /event
Send an event

Send event to Event-Driven Ansible

To send an event to Event-Driven Ansible in your workflow, you need to provide the information listed below.

Field
Description
Required
Event data
The event data to be sent as valid JSON
optional

To create a workflow that sends an event to Event-Driven Ansible

  1. Go to Workflows Workflows and select Add to create a new workflow.

  2. In the Choose trigger panel, select the trigger best suited to your needs.

  3. On the trigger node, select Add to browse available actions.

  4. On one of the information-extracting nodes, select Add, search for Ansible, and select Send event to Event-Driven Ansible.

  5. On each of the remaining information-extracting nodes, select Add and drag the line to the Send event to Event-Driven Ansible action.

  6. In the Send event to Event-Driven Ansible action, select the connection to your Red Hat Event-Driven Ansible Controller.

  7. Configure the event data field as needed. To learn how to use the output of information-extracting notes, see Expression reference.

    The event data must be valid JSON.

  8. To test your workflow, select Run.