Currently running a fresh Foreman 3.2 installation on Ubuntu 20.04. I’ve configured a deployment for ESXi 7.0.2 based on the following procedure …
… with some minor modifications to suit. It works well except for the before_provision hook script which is not being executed.
Production.log shows both after_build and before_provision scripts being discovered but only the after-build script is executed …
[D|app|] Found hook to Host::Managed#after_build, filename 01-prep-esxi-uefimode.sh [D|app|] Found hook to Host::Managed#before_provision, filename 01-esxi-unset-pxeloaders.sh [I|app|] Finished discovering 1 hooks for Host::Managed#after_build [I|app|] Finished discovering 1 hooks for Host::Managed#before_provision [D|app|] Created hook method after_build on Host::Managed [D|app|] Created hook method before_provision on Host::Managed [D|app|0dda1190] custom hook after_build on esxi-vm1.domain.com will be executed if defined. [D|app|0dda1190] Observed after_build hook on esxi-vm1.domain.com [D|app|0dda1190] Running 1 hooks for Host::Managed#after_build [D|app|0dda1190] Running hook: /usr/share/foreman/config/hooks/host/managed/after_build/01-prep-esxi-uefimode.sh after_build esxi-vm1.domain.com
The deployment procedure runs something like this:
- host pxe boots into foreman network via efi
- gets a dhcp lease from foreman server
- boots into the Foreman discovery image efi
- gets discovered successfully
- host is provisioned in Foreman web interface using host group and then Customised Host is clicked
- host is customised accordingly before the Submit button is clicked
- host loads the ESXi installer and installs successfully and then reboots
This is where I expect the before_provision script to kick in which removes the host from build mode. But the script doesn’t run and the host remains in build mode. If I don’t manually cancel the build, the build process starts all over again.
Both scripts are executable:
-rwxr-xr-x 1 foreman foreman 2368 May 19 13:37 01-prep-esxi-uefimode.sh*
-rwxr-xr-x 1 foreman foreman 1285 May 19 13:37 01-esxi-unset-pxeloaders.sh*
Both after_build and before_provision directories have the symlink:
lrwxrwxrwx 1 foreman foreman 94 May 19 08:09 hook_functions.sh → /usr/share/foreman/vendor/ruby/2.7.0/gems/foreman_hooks-0.3.17/examples/bash/hook_functions.sh
I can see the after_build.log file in /tmp/systemd-private-c53966d6d0e0479e938d2944deff09d0-foreman.service-m1h7Mi/tmp. But I can’t find any before_provision.log file anywhere.
The Provisioing Template does have this code:
wget -O /dev/null <%= foreman_url(‘built’) %>
echo “Done with Foreman call”
Any pointers in the right direction to troubleshoot this would be most appreciated.