Access host interface information in "Host Deleted" webhook

Problem:
I am trying to send a hosts interface information to a shellhook script when the host gets deleted. Here is the webhook template I am currently using:

<%=
payload({
  id: @object.id,
  fqdn: @object.name,
  os: @object.os,
  hostgroup: @object.hostgroup,
  interfaces: @object.interfaces
}, with_defaults: true)
-%>

According to /templates_doc/v1/all/Host::Managed.html on our Foreman host, @object.interfaces should return an array of the hosts interface objects. When parsing this template on the “Host Deleted” event, the array is empty though.

Expected outcome:
Hosts interface information in the payload.

Foreman and Proxy versions:
3.2.1

Foreman and Proxy plugin versions:

  • foreman-tasks 6.0.1
  • foreman_bootdisk 19.0.3
  • foreman_discovery 20.0.1
  • foreman_expire_hosts 7.0.4
  • foreman_hooks 0.3.17
  • foreman_puppet 3.0.7
  • foreman_remote_execution 6.0.0
  • foreman_scc_manager 1.8.20
  • foreman_snapshot_management 2.0.1
  • foreman_templates 9.1.0
  • foreman_webhooks 3.0.3
  • katello 4.4.2.2
  • puppetdb_foreman 5.0.0

Distribution and version:
RHEL8

Other relevant data:
This is currently not a big blocker for us, since we cannot migrate from foreman_hooks to a webhook based setup due to other problems, but I would like to keep our codebase prepared for when we need to/are able to switch over.

It feels like the interfaces get removed first so then when you try to access them they don’t exist anymore? I know it doesn’t help at all, but anyway.

CC @ofedoren

That was my guess as well, but in my opinion, this would probably be unintentional. Also I did not want to rule out the possibility that I’m doing something wrong here :wink:

Just to have this here in case anyone wonders, the reason we are not able to migrate to webhooks yet are this bug: Bug #36105: Webhook task creation randomly failes, leaving bogus tasks in state pending/pending - Webhooks - Foreman as well as this bug/missing feature: Feature #36104: As a user, I want to be able to trigger webhooks only on explicit host updates - Webhooks - Foreman