Foreman Hooks - create not working, update and destroy are working

Hi,

I'm trying to get the Foreman hooks to work, specifically a create hook to
populate the hostgroup attribute.

I am using Foreman Version 1.3.1, foreman_hooks-0.3.3-1.el6,
passenger-4.0.5-5.el6, httpd-2.2.15-29.el6 on Red Hat 6.4.

We are trying to use Puppet ENC (node.rb) to update the Foreman Host Group
when Facts are pushed through from Puppet.

The current status is
Foreman hook scripts have been created and registered as follows, entries
from ~foreman/log/production.log

Found hook to Host::Managed#after_commit, filename 30_does_host_exist.py
Found hook to Host::Managed#update, filename 30_does_host_exist.py
Found hook to Host::Managed#after_create, filename 30_does_host_exist.py
Found hook to Host::Managed#create, filename 30_does_host_exist.py
Found hook to Host::Managed#destroy, filename 30_does_host_exist.py

I excute #puppet agent -t on host

  • Puppet ENC node.rb runs successfully
  • Host is created in Foreman
  • Foreman hook after_create script initiates and runs (expected)
  • Foreman hook after_commit script initiates and runs (expected)
  • Foreman hook create script is not initiated and does not run (NOT AS
    EXPECTED
    )
  • Foreman hook update script is not initiated and does not run (expected)
  • Foreman hook destroy script is not initiated and does not run (expected)

The script 30_does_host_exist.py is exactly the same in each hook directory
(including permissions) and all hook directories have the same permissions.

Has anybody else experienced this behaviour, it's as though the create hook
is being excluded entirely. Is there
a seeting somewhere that can exclude hooks?

Regards,
Matt.

I suspect this is because of how the host is being created - via the
Puppet run and a facts upload. Our orchestration system, which
foreman_hooks uses in the create/destroy/update events is triggered
through validations when hosts are created via the web UI or API, but we
explicitly bypass validations and orchestration when hosts are created
through fact or report uploads.

I think the idea is to prevent something like an IP change due to a fact
change from trying to modify DNS or DHCP reservations.

··· On 27/01/14 13:31, Matthew Smith wrote: > Hi, > > I'm trying to get the Foreman hooks to work, specifically a create hook > to populate the hostgroup attribute. > > I am using Foreman Version 1.3.1, foreman_hooks-0.3.3-1.el6, > passenger-4.0.5-5.el6, httpd-2.2.15-29.el6 on Red Hat 6.4. > > We are trying to use Puppet ENC (node.rb) to update the Foreman Host > Group when Facts are pushed through from Puppet. > > The current status is > Foreman hook scripts have been created and registered as follows, > entries from ~foreman/log/production.log > > Found hook to Host::Managed#after_commit, filename 30_does_host_exist.py > Found hook to Host::Managed#update, filename 30_does_host_exist.py > Found hook to Host::Managed#after_create, filename 30_does_host_exist.py > Found hook to Host::Managed#create, filename 30_does_host_exist.py > Found hook to Host::Managed#destroy, filename 30_does_host_exist.py > > > I excute #puppet agent -t on host > - Puppet ENC node.rb runs successfully > - Host is created in Foreman > - Foreman hook after_create script initiates and runs (expected) > - Foreman hook after_commit script initiates and runs (expected) > - Foreman hook create script is not initiated and does not run (*NOT AS > EXPECTED*) > - Foreman hook update script is not initiated and does not run (expected) > - Foreman hook destroy script is not initiated and does not run (expected) > > The script 30_does_host_exist.py is exactly the same in each hook > directory (including permissions) and all hook directories have the same > permissions. > > Has anybody else experienced this behaviour, it's as though the create > hook is being excluded entirely. Is there > a seeting somewhere that can exclude hooks?


Dominic Cleal
Red Hat Engineering