# EDA Webook endpoint

**URL:** <https://forum.ansible.com/t/eda-webook-endpoint/5747>\
**Category:** Get Help\
**Tags:** eda-server\
**Created:** [May 10, 2024, 11:11pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747 "2024-05-10T23:11:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Williams\_Ruter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/williams_ruter/32/3420_2.png) [@Williams\_Ruter](https://forum.ansible.com/u/Williams_Ruter)\
**Post date:** [May 10, 2024, 11:11pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/1 "2024-05-10T23:11:10Z")

</div>

Good evening everyone, if have recently installed EDA by leveraging Docker-Compose and wanted to test very basic function such as Webhook testing. However, while running curl command such as : _ **curl -H “Content-Type: application/json” -d “{“message”: “Hello”}” orion:8000** _  
I’m receiving the following message :  
**The requested resource was not found on this server.**

I check the configuration of the docker-compose-stage.yaml file and the API port listen on 8000, I did also test the url orion:8000/\_healthz and this one is working. Obviously, it’s a GET command, but I’m trying and POST to trigger a job.  
Can anyone have an idea about the endpoint that needs to be used for POST command for EDA ??  
Thank you

---

<div class="post-metadata">

**Author:** ![akira6592](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akira6592/32/222_2.png) [@akira6592](https://forum.ansible.com/u/akira6592)\
**Post date:** [May 11, 2024, 12:46pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/2 "2024-05-11T12:46:00Z")

</div>

@Williams_Ruter Welcome to community!

How about `orion:8000/endpoint` ?

---

<div class="post-metadata">

**Author:** ![Williams\_Ruter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/williams_ruter/32/3420_2.png) [@Williams\_Ruter](https://forum.ansible.com/u/Williams_Ruter)\
**Post date:** [May 11, 2024, 5:53pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/3 "2024-05-11T17:53:18Z")

</div>

Hey Akira,  
I did try with the /endpoint and the result is the same.

---

<div class="post-metadata">

**Author:** ![cloin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cloin/32/171_2.png) [@cloin](https://forum.ansible.com/u/cloin)\
**Post date:** [May 11, 2024, 6:46pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/4 "2024-05-11T18:46:26Z")

</div>

The webhook plugin uses a dynamic URL path to capture any endpoint specified in the URL after the base URL (e.g., `/your-endpoint`), as defined by the route handler:

```python
@routes.post(r"/{endpoint:.*}")

```

In this route definition, `{endpoint:.*}` is a path parameter that captures any text following the base URL as the `endpoint`. This allows the webhook to accept requests at any endpoint under its base address and enables you to simulate different webhook paths easily.

So when you use `curl` to send a request to the webhook, you should specify an endpoint. If you don’t supply one, it might default to just `/`, which might work (I can’t remember testing this). Here is an example to make it clear:

```bash
curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello"}' http://localhost:5000/my-webhook-endpoint

```

The endpoint you specify gets added to the event dictionary under `event.meta` which is nice because you can then use it in your conditions.

---

<div class="post-metadata">

**Author:** ![Williams\_Ruter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/williams_ruter/32/3420_2.png) [@Williams\_Ruter](https://forum.ansible.com/u/Williams_Ruter)\
**Post date:** [May 12, 2024, 6:08pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/5 "2024-05-12T18:08:47Z")

</div>

Hey Cloin,  
Thanks for your reply, i did review the webhook.py from the documentation and i can see that the default port is 5000.  
Since EDA is running in within docker on specific port, i assume that i need to open this specific one ? because if i try on the default port is have this:  
C:\Users\Williams\>curl -X POST -H “Content-Type: application/json” -d “{“message”: “Hello”}” [http://orion:5000/webhook](http://orion:5000/webhook)  
curl: (7) Failed to connect to orion port 5000 after 2075 ms: Couldn’t connect to server

## My configure in the run book is as follow:

- name: Automatic Remediation from Alert Manager  
hosts: all
# execution\_strategy: parallel
sources:
  - name: Test Webhook  
ansible.eda.webhook:  
host: 0.0.0.0  
port: 5000  
rules:
  - name: Launch playbook on start message  
condition: event.payload.message == ‘Ansible is super cool’  
action:  
run\_job\_template:  
name: “Local Test”  
organization: “Home”

And here this the docker-compose-stage.yaml file where is see the web socket listening on port 8000  
eda-api:  
image: “${EDA\_IMAGE:-quay.io/ansible/eda-server:main}”  
environment: \*common-env  
command:  
- /bin/bash  
- -c  
- \>-  
aap-eda-manage migrate  
&& aap-eda-manage create\_initial\_data  
&& scripts/create\_superuser.sh  
&& gunicorn -b 0.0.0.0:8000  
-w ${EDA\_API\_WORKERS:-4} aap\_eda.wsgi  
–access-logfile -  
ports:  
- ‘8000:8000’  
depends\_on:  
redis:  
condition: service\_healthy  
postgres:  
condition: service\_healthy  
healthcheck:  
test: [‘CMD’, ‘curl’, ‘-q’, ‘[http://localhost:8000/\_healthz](http://localhost:8000/_healthz)’ ]

I probably missed something, but i did review the documentation and i don’t see anything about changing port

Any idea ?

---

<div class="post-metadata">

**Author:** ![Alex-Izquierdo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alex-izquierdo/32/679_2.png) [@Alex-Izquierdo](https://forum.ansible.com/u/Alex-Izquierdo)\
**Post date:** [May 13, 2024, 10:56am UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/6 "2024-05-13T10:56:33Z")

</div>

Hi @Williams_Ruter

Indeed, to enable webhooks with the docker-compose of eda-server you have to ensure the connectivity. The ansible-rulebook process that runs the webhook is a container executed in the podman service. Eda-server maps automatically the port inside the service, but if your setup doesn’t provide a way to connect to the podman service directly from outside, you might need to expose that port. For example you can modify the existing docker-compose definition or create a new one to override the service configuration and expose the port, so you can reach the webhook from localhost. localhost:5000-\>podman:5000-\>rulebook:5000

```auto
# my-webhook-override.yml
# docker-compose up -f docker-compose-stage.yml -f my-webhook-override.yml

services:
  podman:
    user: "1000"
    image: quay.io/containers/podman:${EDA_PODMAN_VERSION:-v4}
    privileged: true
    command: >-
      podman system service --time=0 tcp://0.0.0.0:8888
    ports:
      - 8888:8888
      - 5000:5000 # new port for the webhook plugin
    volumes:
      - 'podman_data:/home/podman/.local/share/containers/storage'
    depends_on:
     - podman-pre-setup

```

---

<div class="post-metadata">

**Author:** ![Williams\_Ruter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/williams_ruter/32/3420_2.png) [@Williams\_Ruter](https://forum.ansible.com/u/Williams_Ruter)\
**Post date:** [May 13, 2024, 5:44pm UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/7 "2024-05-13T17:44:12Z")

</div>

Hey Alex,  
Thank you very much for the pointing this out, i did change the config and it is flying now. My next question is : why is it not mention anywhere in the documentation on EDA ?  
It is probably … i assume somewhere … so if it’s the can do you by any chance where this is located ?

Again thank you for your guidance.

---

<div class="post-metadata">

**Author:** ![Alex-Izquierdo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alex-izquierdo/32/679_2.png) [@Alex-Izquierdo](https://forum.ansible.com/u/Alex-Izquierdo)\
**Post date:** [May 14, 2024, 11:33am UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/8 "2024-05-14T11:33:03Z")

</div>

@Williams_Ruter I agree that it could be documented; we still need to create complete documentation for the EDA server. Also, take into account that Docker Compose is limited and mostly intended for testing purposes. Covering all the potential customizations may be challenging, especially with webhooks, which always require additional configurations for outbound connections that depend on your setup and network. (port-forwardings, ingresses, firewalls, etc…)

The webhook pattern can be an easy way for a quick demonstration, but we don’t recommend it for a real production environment unless there are no better options:  
[https://ansible.readthedocs.io/projects/rulebook/en/latest/sources.html#best-practices-and-patterns](https://ansible.readthedocs.io/projects/rulebook/en/latest/sources.html#best-practices-and-patterns)

Anyway we are working to change how webhooks are used and handled directly from the EDA server instead of through the rulebook, making it easier to configure and use them. Hopefully, we can implement this in the second half of 2024

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 13, 2024, 11:33am UTC](https://forum.ansible.com/t/eda-webook-endpoint/5747/9 "2024-06-13T11:33:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
