Problem:
Foreman_hooks actually doesn’t work for my physical machine.
I’'ve tried to follow steps from: RHEL guide - Foreman hooks and the Github page.
I’ve tried to create /usr/share/foreman/config/hooks/host/managed/create with the two script: 10_logger.sh:
I also receive the following error message, which I am unsure is from my hooks:
Not queueing Host::Managed: [“Ip is too long (maximum is 15 characters)”, “Ip is invalid”]
I can ensure you all that Foreman is able to find the hooks, but not able to execute it seems:
[I|app|] Finished discovering 2 hooks for Host::Managed#create*
# Utilities for hook scripts, used with foreman_hooks
#
# Source this at the start of any bash hook script:
#
# . hook_functions.sh
#
# It reads in a JSON representation of the object and then provides a
# hook_data wrapper around jgrep to read fields from it, e.g.
#
# hostname=$(hook_data host.name)
# comment=$(hook_data host.comment)
# update, create, before_destroy etc.
HOOK_EVENT=$1
# to_s representation of the object, e.g. host's fqdn
HOOK_OBJECT=$2
HOOK_OBJECT_FILE=$(mktemp -t foreman_hooks.XXXXXXXXXX)
trap "rm -f $HOOK_OBJECT_FILE" EXIT
cat > $HOOK_OBJECT_FILE
hook_data() {
if [ $# -eq 1 ]; then
jgrep -s "$1" < $HOOK_OBJECT_FILE
else
jgrep "$*" < $HOOK_OBJECT_FILE
fi
}
Ok, that make sense. Right now i’m having hooks for creating host, but what i’m actually doing is re-building an existing host… Making me unsure of what “event” I should actually use. It should be something with after_build/provisioned.