environment variables and hooks

I am using the hook system to run some code, but the code needs to read an environment variable. However I have tried putting the env var in a few places and even though when i run ‘env’ as the oneadmin user I can see the env var when the hook runs it doesn’t find it.

How do I get env vars to be accessible to code in hooks ?
This is on ubuntu.

Hi @Sean_JC,

Hooks are executed by one-hem server. They are executed as subprocesses, so they will inherit the environment information from it. So any environment variable you define for one-hem server process should be available for the hook execution. For example, you can define environment variables in the opennebula-hem.service service unit file (note that these files might be overwritten on packages updates).

1 Like