I have problem with action hooks and shell hooks. Action hooks didnt register. I created simple bash script:
~ cat /usr/share/foreman/config/hooks/host/managed/(update|destroy|after_destroy)/hook_functions.sh
#!/bin/bash
echo "$(date) >> /tmp/hook.log
exit 0
but hook not runned if i update or destroy host. I see actions in debug-log but there is no mention of actions hook. I havent any idea.
I installed ruby-smart-proxy-shellhooks and i attempt call url:
curl -k -X POST -u admin:PASS -H ‘Content-Type: text/plain’ --data “This is a test” https://domain/shellhooks/print_body
i get it from manual but in have 404 error:
2024-09-20T15:33:53 [I|app|eb3ae283] Started POST “/shellhooks/print_body” for IP at 2024-09-20 15:33:53 +0000
2024-09-20T15:33:53 [F|app|eb3ae283]
eb3ae283 | ActionController::RoutingError (No route matches [POST] “/shellhooks/print_body”):
eb3ae283 |
eb3ae283 | lib/foreman/middleware/logging_context_request.rb:11:in `call’
i restarted foreman with systemd. I noticed that “touch ~foreman/tmp/restart.txt doest” restart server but it also didnt work.
Can anybody help me?
Expected outcome:
Foreman and Proxy versions: 9999-3.12.0-jammy+scratchbuild+20240816182603+ubuntu2204
Hi,
you seem to be mixing the old hooks plugin and shellhooks together.
This would have been honored by the old foreman_hooks plugin. It was replaced with foreman_webhooks. Additionally, even with the old plugin, the hooks couldn’t be triggered by calling the api, the hooks were fired strictly as a reaction to things happening inside foreman.
The scripts for shellhooks should go to /var/lib/foreman-proxy/shellhooks
That’s a start, but it seems that you’re sending this request to your foreman, instead of to the smart proxy. Shellhooks is a smart proxy plugin, so to trigger it manually, you have to send a request to the smart proxy.
Yes, of course. I expected the script to be executed when a host is created, updated or deleted. But foreman doesnt run scripts in hooks/host/managed/update when host updated