Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 4. Integrating Event-Driven Ansible with the Red Hat Hybrid Cloud Console
You can use Event-Driven Ansible to take advantage of Hybrid Cloud Console capabilities such as Red Hat Insights to continuously analyze your inventory for potential issues and recommendations. Event-Driven Ansible connects sources of events with corresponding actions through rules.
The integration with the Hybrid Cloud Console notifications service uses Event-Driven Ansible to trigger actions. Each account configures how and who can receive these events, with the ability to perform actions depending on the event type.
Contacting support
If you have any issues with the Hybrid Cloud Console integration with Event-Driven Ansible, contact Red Hat for support. You can open a Red Hat support case directly from the Hybrid Cloud Console by clicking Help (? icon) > Open a support case, or view more options from ? > Support options.
4.1. Configuring Event-Driven Ansible for integration with the Red Hat Hybrid Cloud Console
You can configure Event-Driven Ansible to receive event notifications from the Red Hat Hybrid Cloud Console or a third-party application.
Prerequisites
-
The
ansible-rulebook
CLI is installed. See Ansible rulebook installation for instructions. - You have Organization Administrator or Notifications administrator permissions for the Hybrid Cloud Console.
Procedure
Connect your environment to the Red Hat Ansible Automation Hub:
- In the Hybrid Cloud Console, navigate to Ansible Automation Platform > Connect to Hub.
- Under Offline token, copy the string under The token will expire after 30 days of inactivity. Run the command below periodically to prevent your token from expiring.
- In a terminal window, paste the string that you copied in the previous step.
Enter the following command to install the Red Hat Insights collection for Event-Driven Ansible:
$ ansible-galaxy collection install redhat.insights_eda
To install the Red Hat Insights requirements, enter the following command as the
root
user:# pip3 install -r ~/.ansible/collections/ansible_collections/redhat/insights_eda/requirements.txt
Enter the following command and verify that
redhat.insights_eda
is included in the output:$ ansible-galaxy collection list
Sample output for this command:
# /home/username/.ansible/collections/ansible_collections Collection Version ------------------ ------- ansible.eda 1.3.8 community.general 7.0.1 redhat.insights_eda 1.0.0
Use a text editor to create a YAML file that contains a simple Ansible rulebook that uses the Red Hat Insights collection. For example, create a file called
simple-rulebook.yaml
with the following content:--- - name: Listen for events from Red Hat Insights hosts: all sources: - redhat.insights_eda.insights: rules: - name: Handle Red Hat Insights payload condition: event.payload is defined action: debug: msg: "Received: {{ event.payload }}"
This simple playbook uses the
redhat.insights_eda.insights
collection as the source. If an event withpayload
is defined, the contents ofevent.payload
are displayed as output.The rulebook exposes an endpoint that is used to receive events and communicate with the Hybrid Cloud Console. See the Event-Driven Ansible for Red Hat Insights documentation in Ansible Automation Hub for more advanced examples for the Red Hat Insights Advisor, Compliance, and Vulnerability services.
Create a YAML file that contains an associated playbook. For example, create a file called
inventory.yaml
that contains a simple inventory:all:
Run the
ansible-rulebook
command to start your Event-Driven Ansible listener to listen for new events. In the following example, this command exposes yourlocalhost
on the default port 5000:$ ansible-rulebook --verbose --rulebook simple-rulebook.yml -i inventory.yml
Run the
curl
command in a separate terminal window to verify that your Event-Driven Ansible listener is configured correctly, for example:$ curl -H 'Content-Type: application/json' -d "{\"payload\": \"Test incoming event\"}" localhost:5000/endpoint
In this example, if the configuration is correct, a new message appears in the EDA listener window with the content of the event:
Received: {'payload': 'Test incoming event'}
- In the Hybrid Cloud Console, navigate to Settings > Integrations.
- Select the Reporting & Automation tab.
- Click Add integration.
- Select Event-Driven Ansible as the integration type, and then click Next.
- In the Integration name field, enter a name for your integration (for example, My EDA Integration).
Enter the URL that you configured in your Ansible rulebook into the Endpoint URL field. This is the endpoint that points to the Event-Driven Ansible listener.
NoteThe Endpoint URL must include
http://
orhttps://
, for examplehttps://<eda_hostname>:5000/endpoint
.If necessary, ask the security administrator for your organization to configure access to the Red Hat Hybrid Cloud Console.
Optional: Enter a Secret token if one is configured.
NoteA secret token is essential for protecting the data sent to the integration endpoint and should always be used when integrating the Hybrid Cloud Console with third-party applications.
- Click Next.
- Review the integration details, and then click Submit to enable the integration.
Your Event-Driven Ansible integration is now listed on the Integrations > Reporting & Automation page. Under Last connection attempt, the status is Ready to show the connection can accept notifications from the console.
Verification
Create a test notification to confirm you have correctly connected Event-Driven Ansible to the Hybrid Cloud Console:
- Next to your Event-Driven Ansible integration on the Integrations > Reporting & Automation page, click the options icon (⋮) and click Test.
- In the Integration Test screen, enter a message and click Send. If you leave the field empty, the Hybrid Cloud Console sends a default message.
- In the Event-Driven Ansible listener terminal, check for the message sent from the Hybrid Cloud Console.
- In the Hybrid Cloud Console, go to Notifications > Event Log and check that the Integration: Event-Driven Ansible event is listed with a green label.
Additional resources
- For more information about setting up Notifications administrator permissions, see Configure User Access to manage notifications in Configuring notifications on the Red Hat Hybrid Cloud Console.
-
For more Event-Driven Ansible configuration information and examples of Red Hat Insights rulebooks, see the Documentation tab in the
insights_eda
collection available from the Ansible Automation Hub Collections page.
4.2. Creating the behavior group for the Event-Driven Ansible integration
A behavior group defines which notifications will be sent to external services such as Event-Driven Ansible when a specific event is received by the notifications service. You can link events from any Red Hat Hybrid Cloud Console service to your behavior group.
Prerequisites
- You are logged in to the Hybrid Cloud Console as an Organization Administrator or as a user with Notifications administrator permissions.
- The Event-Driven Ansible integration with the Hybrid Cloud Console is configured. See Section 4.1, “Configuring Event-Driven Ansible for integration with the Red Hat Hybrid Cloud Console” for information about configuring Event-Driven Ansible integration.
Procedure
- In the Hybrid Cloud Console, navigate to Settings > Notifications.
- Under Notifications, select Configure Events.
- Select the application bundle tab you want to configure event notification behavior for: Red Hat Enterprise Linux, Console, or OpenShift.
- Click the Behavior Groups tab.
- Click Create new group to open the Create behavior group wizard.
- Type a name for the behavior group and click Next.
- In the Actions and Recipients step, select Integration: Event-Driven Ansible from the Actions drop-down list.
- From the Recipient drop-down list, select the name of the integration you created (for example, My EDA Listener) and click Next.
- In the Associate event types step, select one or more events for which you want to send notifications (for example, Advisor: New recommendation) and click Next.
- Review your behavior group settings and click Finish. The new behavior group appears on the Notifications page.
Verification
- Create an event that will trigger a Hybrid Cloud Console notification. See the Ansible Automation Hub page for an example.
To test that the Hybrid Cloud Console integration was successful, in the Hybrid Cloud Console, go to Settings > Notifications > Event Log and check for an event that shows the label Integration: Event-Driven Ansible.
- If the label is green, the notification succeeded.
- If the label is red, verify that the webhook has been properly created and exposed in Event-Driven Ansible, and that the correct webhook URL is configured in the Hybrid Cloud Console integration configuration.
See Troubleshooting notification failures with the event log and integration settings in the notifications documentation for more details.
4.3. Additional resources
- For more information about Event-Driven Ansible, see the Getting Started with Event-Driven Ansible Guide.
- For information about how to configure and use the Event-Driven Ansible controller, see Event-Driven Ansible controller user guide.
- For more information about behavior groups, see Configuring Hybrid Cloud Console notification behavior groups.
- For configuration examples, see Red Hat Insights Collection for Event-Driven Ansible and Using Red Hat Insights as a source of events for Event-Driven Ansible automation in the Red Hat Ansible blog.
- For information about troubleshooting your Event-Driven Ansible integration, see Troubleshooting Hybrid Cloud Console integrations.