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
Let’s go to Monitoring > Hosts:
Click on Create Host:
Host name: node1.example.com
Templates, click in select.
Click select again:
From the list, select Operating System:
Then, Linux by zabbix agent
Click select again:
Let’s add another template, Click on select again:
click on Templates/application
Now, Apache by agent Zabbix Agent
In Host Group, click select and select Applications
Now in interface. Click on Add and then click agent
In Connect to. Change to DNS: (IMPORTANT)
Click DNS next to IP and add DNS name:
DNS name: node1.example.com
Now click on Add(Blue)
Wait 15 seconds. Press F5 to refresh the browser. Turning Green on Available. Everything is OK.
Let’s configure Zabbix to send events to Event Driven: Alerts > Actions > Trigger actions: Enable Report problems to Zabbix administrators: Before:
After. After clicking on Disabled(Red). It will change to Enabled(Green):
Let’s enable the Media Type:
Alerts > Media Type > Event Driven Ansible. Click on Disabled(Red). It will change to Enabled(Green):
Now let’s go to: Users > Users
Click Admin user
Click on the Media tab:
Let’s add the Controller IP. First click Media, and then Add under Type:
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
Click on Update
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
[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:
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:
Let’s create the rulebook:
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
Find the error and remediate. |
Now the rulebook will start:
Click on the rulebook name: eda-debug
Access History:
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. |
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
In eda we can see the playload arriving.
{'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
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.
-
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