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
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:
@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:
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.
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
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’ ]
I probably missed something, but i did review the documentation and i don’t see anything about changing port
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
# 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
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 ?
@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…)
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