Hi, Is it possible to capture the host’s MAC address in a foreman-hook script? I know that the first and second args are the event name and hostname but I need the MAC address.
A JSON representation of the hook object will be passed in on stdin. A utility to read this with jgrep is provided in examples/hook_functions.sh and sourcing this utility script will be enough for most users. Otherwise, you may want to ensure stdin is closed to prevent pipe buffer from filling.
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_hooks-0.3.14/examples/python/host/managed/create/10-logger.py as reference. However that script has an error:
mac_address = HOOK_JSON.get('host').get('mac', None)
it should be
mac_address = HOOK_JSON.get('host').get('host').get('mac', None)
Looks like there is already an open issue for this: