and i already tested foreman_hooks tag = 0.3.4 & 0.3.7
and also reference hook_functions.sh & jgrep ruby gem already installed.
but I can not get json data, here is my hook script.
#!/bin/bash
HOOK_EVENT=$1
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
}
echo "current path = $(dirname $0)" >> /tmp/hook.log
# event name (create, before_destroy etc.)
# orchestration hooks must obey this to support rollbacks (create/update/destroy)
event=${HOOK_EVENT}
# to_s representation of the object, e.g. host's fqdn
object=${HOOK_OBJECT}
# Example of using hook_data to query the JSON representation of the object
# passed by foreman_hooks. `cat $HOOK_OBJECT_FILE` to see the contents.
hostname=$(hook_data host.name)
echo "$(date): received ${event} on ${object}" >> /tmp/hook.log
echo "hostname = ${hostname}" >> /tmp/hook.log
# exit code is important on orchestration tasks
exit 0
I can correct get $event & $object variable in output log.
but my $hostname is always empty.
my foreman version = 1.4.2
and i already tested foreman_hooks tag = 0.3.4 & 0.3.7
and also reference hook_functions.sh & jgrep ruby gem already installed.
but I can not get json data, here is my hook script.
I can correct get $event & $object variable in output log. but my $hostname is always empty.
is it a bug? or just my mismatch configuration?