Foreman_hooks plugin

Hello,

I'm trying to use the foreman_hooks plugin.

My problem is that it doesn't appear to do anything, and there is nothing
in any log I am aware of that indicates that foreman has even picked up the
existence of the plugin…

Situation:
System RHEL 6.4
Foreman: 1.3

I installed the plugin using "yum install ruby193-rubygem-foreman_hooks"
followed by a "service httpd restart"

Then I created the dir
/usr/share/foreman/config/hooks/host/managed/create/

In this dir I created a small script, that only copies the data it receives
to a /tmp file…

#!/bin/bash
HOOK_EVENT=$1
HOOK_OBJECT=$2
HOOK_OBJECT_FILE=$(mktemp --tmpdir=/tmp foreman_hooks.XXXXXXXXXX)
echo $HOOK_EVEN > $HOOK_OBJECT_FILE
echo $HOOK_OBJECT >> $HOOK_OBJECT_FILE
cat >> $HOOK_OBJECT_FILE

Now when I create a host via the web interface I expect this script to be
triggered. However it is not. All the other things foreman must do (add
dhcp entries, setup tftp…) it does, but the script appears to be ignored.
The log file doesn't give me any helpful indication as well.

What should I do now? How do I investigate this further?

> Hello,
>
> I'm trying to use the foreman_hooks plugin.
>
> My problem is that it doesn't appear to do anything, and there is
> nothing in any log I am aware of that indicates that foreman has even
> picked up the existence of the plugin…
>
> Situation:
> System RHEL 6.4
> Foreman: 1.3
>
> I installed the plugin using "yum install
> ruby193-rubygem-foreman_hooks" followed by a "service httpd restart"
>
> Then I created the dir
> /usr/share/foreman/config/hooks/host/managed/create/

Be sure to restart Foreman after installing any scripts, since the
plugin will search for them when the Foreman app starts up in order to
register for events.

"service foreman restart" should suffice.

> In this dir I created a small script, that only copies the data it
> receives to a /tmp file…
>
> #!/bin/bash
> HOOK_EVENT=$1
> HOOK_OBJECT=$2
> HOOK_OBJECT_FILE=$(mktemp --tmpdir=/tmp foreman_hooks.XXXXXXXXXX)
> echo $HOOK_EVEN > $HOOK_OBJECT_FILE
> echo $HOOK_OBJECT >> $HOOK_OBJECT_FILE
> cat >> $HOOK_OBJECT_FILE
>
> Now when I create a host via the web interface I expect this script to
> be triggered. However it is not. All the other things foreman must do
> (add dhcp entries, setup tftp…) it does, but the script appears to be
> ignored. The log file doesn't give me any helpful indication as well.
>
> What should I do now? How do I investigate this further?

If the restart doesn't help, begin by dropping to debug logging, since
the plugin will log about any hooks it does find and register, then
again when the events fire.

See
http://projects.theforeman.org/projects/foreman/wiki/Troubleshooting#How-do-I-enable-debugging

Then restart Foreman again. To find any related messages, just run
"grep -i hook /var/log/foreman/production.log".

··· On 23/10/13 13:56, Krist van Besien wrote:


Dominic Cleal
Red Hat Engineering

I dropped to debug logging, and now it seems to work. Strange…

Next step is having my script do something useful. (pre stage the host in
IPA in this case…)

Krist

··· On Wednesday, October 23, 2013 3:21:52 PM UTC+2, Dominic Cleal wrote: > > > If the restart doesn't help, begin by dropping to debug logging, since > the plugin will log about any hooks it does find and register, then > again when the events fire. > > See > > http://projects.theforeman.org/projects/foreman/wiki/Troubleshooting#How-do-I-enable-debugging > > Then restart Foreman again. To find any related messages, just run > "grep -i hook /var/log/foreman/production.log". >