Foreman hooks examples


Foreman ships with the new Webhooks plugin for more advanced hooking capabilities. I would like to write a blogpost about migrating Foreman hooks to Webhooks, but I need some real-world foreman hook examples.

Can you paste bin some of your hooks you use in production? Feel free to anonymize it, it does not need to be working just to get an idea of what folks do.

What I offer in exchange is that I include your hook in the blogpost describing what would be the best approach to migrate to Webhooks. :slight_smile:


In my case, I have two Foreman instances. One is the stable one which performs the configuration of machines through Ansible and maintains the more or less production environment. Second is a nightly instance that I use for various testing and where I provision many machines of various types. I didn’t want to have two instances with the same Ansible roles and keeping both up to date, instead I use webhooks so that the when I provision a machine in the dev one, I also create it in prod one by using webhooks and then trigger Ansible run on it. On host deletion, it deletes the host from prod Foreman. Prod Foreman uses different interface and FQDN to access the host, so the webhooks template actually changes the host domain during the creation or deletion.

Let me know if you want more details, I guess the use-case of host creation/deletion upon provisioning, destroy is quite common. It does not have to be second Foreman instance, but e.g. monitoring tool, business process management or anything that you want to update with the new record.

1 Like