Is there a way for me to associate some internal ruby event to a hook to run something for me on subnet creation?
I’m looking for something similar to host/discovered/[after_commit|after_create|after_destroy] so I can automate subnet creation/deletion of said subnet in DHCP config and restart ISC dhcpd after that.
Hmm, even though Foreman does recognize a simple script I put under ~foreman/config/hooks/subnet/{after_commit,after_create,after_destroy}/log.sh, I don’t see that script executed:
2018-09-06 14:44:06 [app] [D] Found hook to Subnet#after_destroy, filename 00_log.sh
2018-09-06 14:44:06 [app] [D] Found hook to Subnet#after_create, filename 00_log.sh
2018-09-06 14:44:06 [app] [D] Found hook to Subnet#after_commit, filename 00_log.sh
2018-09-06 14:44:06 [app] [I] Finished discovering 1 hooks for Subnet#after_destroy
2018-09-06 14:44:06 [app] [I] Finished discovering 1 hooks for Subnet#after_create
2018-09-06 14:44:06 [app] [I] Finished discovering 1 hooks for Subnet#after_commit
2018-09-06 14:44:09 [app] [D] Extending Subnet with foreman_hooks Rails hooking support
2018-09-06 14:44:09 [app] [D] Created hook method after_destroy on Subnet
2018-09-06 14:44:09 [app] [D] Created hook method after_create on Subnet
2018-09-06 14:44:09 [app] [D] Created hook method after_commit on Subnet
On a subnet deletion/update/create, I only see this in a log:
2018-09-06 14:47:10 6e900e71 [app] [D] Observed after_commit hook on
Instead of expected output like this (other hooks on the same Foreman instance):
Yes, everything with the script is perfectly fine. In fact, that’s just a symlink to the same script that host/managed hooks use and the latter have no issues with it as you can see in my example above.
I agree, this seems like something that should just work, but it does not and I’m puzzled here…
Can you drop the symlink and do a copy? SELinux might be preventing that. Absolute symlinks are also problem sometimes (not in this context but in chroots).