Configure Event Drive to send Extra Variables to AAP.

What’s in this break-fix?

In this section, we will send a curl to Event-Driven Ansible(Automation Decisions). Event-Driven Ansible(Automation Decisions) needs to execute the Jobs Template: rh1-aap-extra-vars-eda

Let’s add a node in zabbix:

Let’s run the client-zabbix playbook on the Ansible Automation Platform to configure the Zabbix agent on the host apache001 Loging in Zabbix http://server.{subdomain_base}/zabbix/.

User: Admin
Pass: zabbix
lab004-001

Let’s go to Monitoring > Hosts:

Click on Create Host:

lab004-002
Host name: node1.example.com

Templates, click in select.

lab004-003

Click select again:

lab004-004

From the list, select Operating System:

lab004-005

Then, Linux by zabbix agent

Click select again:

lab004-006

Let’s add another template, Click on select again:

lab004-007

click on Templates/application

lab004-008

Now, Apache by agent Zabbix Agent

lab004-009

In Host Group, click select and select Applications

lab004-010

Now in interface. Click on Add and then click agent

lab004-011

In Connect to. Change to DNS: (IMPORTANT)

lab004-012

Click DNS next to IP and add DNS name:

DNS name: node1.example.com
lab004-013

Now click on Add(Blue)

lab004-014

Wait 15 seconds. Press F5 to refresh the browser. Turning Green on Available. Everything is OK.

lab004-015

Let’s configure Zabbix to send events to Event Driven: Alerts > Actions > Trigger actions: Enable Report problems to Zabbix administrators: Before:

lab004-016

After. After clicking on Disabled(Red). It will change to Enabled(Green):

lab004-017

Let’s enable the Media Type:

Alerts > Media Type > Event Driven Ansible. Click on Disabled(Red). It will change to Enabled(Green):

lab004-018

Now let’s go to: Users > Users

lab004-020

Click Admin user

lab004-021

Click on the Media tab:

lab004-020

Let’s add the Controller IP. First click Media, and then Add under Type:

lab004-022
lab004-023

To find the IP log into the controller and run ip ad ls

[lab-user@bastion ~]$ ssh controller
Last login: Thu Nov 21 14:12:38 2024 from 192.168.0.144
[ec2-user@controller ~]$
[ec2-user@controller ~]$
[ec2-user@controller ~]$ ip ad ls
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 02:ca:6e:57:61:5f brd ff:ff:ff:ff:ff:ff
    altname enp0s5
    altname ens5
    inet 192.168.0.131/24 brd 192.168.0.255 scope global dynamic noprefixroute eth0
       valid_lft 2868sec preferred_lft 2868sec
    inet6 fe80::ca:6eff:fe57:615f/64 scope link
       valid_lft forever preferred_lft forever
[ec2-user@controller ~]$

In this example the IP: 192.168.0.131.

Now add the IP of the controller and the Rulebook port of 5000 to Send to:

192.168.0.131:5000

Now click on Add

lab004-024

Click on Update

lab004-025

Now our Zabbix is ​​monitoring node1. If there is any alert, it will be sent to Event Driven.

Now on the terminal

cd 04-lab/
git clone git@server.example.com:root/eda-debug.git
cp -rf rulebooks eda-debug/
cd eda-debug/
git add . ; git commit -m add ; git push
Output
[ec2-user@node1 ~]$ cd 04-lab/
[ec2-user@node1 ~]$ git clone git@server.example.com:root/eda-debug.git
[ec2-user@node1 04-lab]$ cp -rf rulebook eda-debug/
[ec2-user@node1 04-lab]$ cd eda-debug/
[ec2-user@node1 eda-debug]$ git add . ; git commit -m add ; git push

Let’s now create the Rulebook in Decisions to receive these Alerts:

Now on the Ansible Automation Platform:

Open the URL if you need to: https://controller.{subdomain_base}/

Let’s log in:

User: admin
Pass: R3dh4t1!

Let’s first create the project in Automation Decision:

Click on Create project:

lab004-026
Name: eda-debug
Organization: Default
Source control type: Git
Source control URL: https://server.example.com/root/eda-debug.git
Source control credential: gitlab
Options: uncheck Verify SSL

After you have created the project. The project will sync and then finish successfully:

lab004-028

Let’s create the rulebook:

lab004-030

Now let’s create the RuleBook:

Click on Create Rulebook activation:

Name: eda-debug
Organization: Default
Project: eda-debug
Rulebook: webhook-debug.yml
Credential: AAP
Decision environment: Default Decision Environment
lab004-031
Find the error and remediate.

Now the rulebook will start:

lab004-032

Click on the rulebook name: eda-debug

Access History:

lab004-033

Access the node1 terminal:

ssh node1
sudo systemctl stop httpd

In the Zabbix Dashboards

We will be able to see the Apache alert being sent to the EDA:

It takes about 30 seconds and a browser refresh to show it under Actions.
lab004-034
The red line under Actions in the Current Problems section. This is a failure you must clear.

Restart httpd in the node1 terminal and clear the error before moving on.

ssh node1
sudo systemctl start httpd
lab004-035

In eda we can see the playload arriving.

lab005-add001
Output
{'hosts': ['all'],
 'inventory': '',
 'project_data_file': '',
 'rule': 'Output Zabbix Information',
 'rule_run_at': '2024-11-26T18:13:47.455882Z',
 'rule_set': 'Listen for events on a webhook from Zabbix',
 'rule_set_uuid': '9ccc3577-5045-4ce3-b72a-97c229bdb042',
 'rule_uuid': 'a643a63e-72c1-485f-a228-c410e08e0d60',
 'variables': {'event': {'meta': {'endpoint': 'endpoint',
                                  'headers': {'Accept': '*/*',
                                              'Accept-Encoding': 'deflate, '
                                                                 'gzip, br',
                                              'Content-Length': '813',
                                              'Content-Type': 'application/json',
                                              'Host': '192.168.0.135:5000'},
                                  'received_at': '2024-11-26T18:13:47.400499Z',
                                  'source': {'name': 'Listen for alerts from '
                                                     'Zabbix',
                                             'type': 'ansible.eda.webhook'},
                                  'uuid': 'dc3d7651-c374-4a95-9169-73e5f269db33'},
                         'payload': {'HTTPProxy': '',
                                     'acknowledged': 'No',
                                     'endpoint': '/endpoint',
                                     'event_date': '2024.11.26',
                                     'event_datetime_timestamp': 1732644824,
                                     'event_id': 110,
                                     'event_name': 'Apache: Service is down',
                                     'event_nseverity': 3,
                                     'event_object': 0,
                                     'event_severity': 'Average',
                                     'event_source': 0,
                                     'event_tags': {'class': ['software'],
                                                    'component': ['application',
                                                                  'health',
                                                                  'system'],
                                                    'scope': ['availability'],
                                                    'target': ['apache']},
                                     'event_time': '18:13:44',
                                     'event_value': 1,
                                     'host_groups': ['Applications'],
                                     'host_host': 'node1.example.com',
                                     'host_id': 10631,
                                     'host_ip': '127.0.0.1',
                                     'host_port': '10050',
                                     'monitoring_source': 'Zabbix sever',
                                     'operation_data': 'Down (0), 0',
                                     'send_to': '192.168.0.135:5000',
                                     'subject': 'Event ID: 110, Host: '
                                                'node1.example.com, Problem: '
                                                'Apache: Service is down',
                                     'trigger_description': '',
                                     'trigger_id': 23758,
                                     'trigger_name': 'Apache: Service is '
                                                     'down'}}}}
********************************************************************************

PAUSE


Before moving ahead

Please take a moment to solve the challenge on your own.

The real value of this activity lies in your effort to troubleshoot independently.

Once you have tried, continue to the next section for guided steps to verify your approach or learn an alternate solution.


CONTINUE


Guided solution

We are looking for what we can use from this payload:
 'event_name': 'Apache: Service is down',
 'host_host': 'node1.example.com',

In the next lab, we will customize the rulebook to take this event_name as a condition!

We will use this playload to solve the apache problem.

  1. The rulebook folder name is missing the S:

cd 04-lab/
cd eda-debug/
mv  rulebook rulebooks
git add . ; git commit -m add ; git push