Foreman Additional One-Off Tasks During Host Provisioning/Removal

Problem:
When I provision or remove hosts within Foreman+Katello+Ansible, I don’t know how to perform additional one-off tasks on other hosts to finalize the provisioning/removal.

Expected outcome:
When I provision a host within Foreman+Katello+Ansible, I need to perform a few additional manual tasks on other hosts:

  1. Add the host to my LibreNMS monitoring system.
  2. Add the host to my NFSen collector.
  3. Add manual DHCPv6 reservations (until ISC DHCPv6 OMAPI supports IPv6 and Foreman supports that).

Likewise, if I am removing the host I need to perform similar removal steps like those above (replacing “add” with “remove”). Ideally, this could be done via one-off Ansible tasks within Foreman itself. For example, once a host is provisioned, an Ansible task is executed against the LibreNMS server to add the host to monitoring. I’m curious, however, what other people do in these particular scenarios or whether Foreman+Ansible supports this and I’m just not seeing in documentation how to accomplish it.

Foreman and Proxy versions:
foreman-release-3.1.2-1.el8.noarch

Foreman and Proxy plugin versions:
ansible-core-2.12.2-2.el8.x86_64
katello-common-4.3.0-1.el8.noarch

Distribution and version:
CentOS 8 Stream

Other relevant data:

Hi,

you could take a look at Foreman Webhooks/Shellhooks for these kind of actions.
We still use the Foreman Hooks Plugin for these kind of integrations, but that seems to be legacy and not maintained anymore. Due to this, I have not looked into working with web- and shellhooks in greater detail, but from what you describe I could imagine shellhooks could work for your use-cases.
As far as I know, there is currently no other method available in Foreman to trigger actions on another host on certain trigger conditions.

1 Like

Perfect. That’s exactly what I was looking for.