There are several scripts automatically executed before the actual action command starts.
This behaviour can be overridden by specifying a different Docker-image in the packet file definition, if this feature is enabled.
Scripts are executed in the following order:
Before modules are enabled, packet files with a name that starts with ‘init_instance.’ are executed. These files can first be parsed with Apache Velocity so that environment variables and such can be made available for the other scripts below.
Packet infraxys-system-include-always uses this to create environment variables for attributes that have been configured for the “container” or “environment”-level. This packet is typically added to a container that’s shared through the root-project. This way all instances of all environments will automatically have this functionality.
After all modules are made available, files in every enabled module-root that have a name starting with ‘init.’ (include the dot ‘.') are executed in alphabetical order.
The current working directory is set to that of the init-file before it’s being sourced.
Use it for things like:
This file is run with the current-directory at the root of the module, so the current working directory is always that of init.sh.
Example init.150.sh:
export PYTHONPATH="$(pwd)/bin:$PYTHONPATH";
export MY_MODULE_ROOT="$(pwd)";
# enable all shell-functions defined in files under "shared":
for f in shared/*.sh; do
source $f;
done;
After all init.* files have run, a list is generated of all files, for every enabled module, that are under module-root “auto-source”.
These files are sourced in alphabetical order.
Use this to make custom bash-functions available, run code that needs other modules to be configured, …
The next iteration is sourcing all files with a name starting with ‘after_modules_enabled.’ in the enabled module-roots.
Use this to execute code after all modules are configured but before (non-init.*) instance-scripts are executed.
Before the actual action is executed, all packet files under the current instance that have a name starting with ‘after_modules_enabled.’ are sourced.
The Terraform Helper packet uses this to gather all Terraform-related files from all instances under the currently running one. This helper-packet is typically inherited by other packets that use Terraform.