fora.loader
Provides the dynamic module loading utilities.
Attributes
attr loader.script_stack
loader.script_stack
loader.script_stack: list[tuple[ScriptWrapper, inspect.FrameInfo]] = []
A stack of all currently executed scripts ((name, file), frame).
class loader.ImmediateInventory
loader.ImmediateInventory
A temporary inventory just for a single run, without the ability to load host or group module files.
def ImmediateInventory.base_dir()
ImmediateInventory.base_dir()
def ImmediateInventory.base_dir(self) -> str:
An immediate inventory has no base directory.
def ImmediateInventory.group_module_file()
ImmediateInventory.group_module_file()
def ImmediateInventory.group_module_file(self, name: str) -> Optional[str]:
An immediate inventory has no group modules.
def ImmediateInventory.host_module_file()
ImmediateInventory.host_module_file()
def ImmediateInventory.host_module_file(self, name: str) -> Optional[str]:
An immediate inventory has no host modules.
def ImmediateInventory.available_groups()
ImmediateInventory.available_groups()
def ImmediateInventory.available_groups(self) -> set[str]:
An immediate inventory has no groups.
Functions
def loader.load_inventory()
loader.load_inventory()
def loader.load_inventory(inventory_file_or_host_url: str) -> None:
Loads the global inventory from the given filename or single-host url and validates the definintions.
Parameters
inventory_file_or_host_url: Either a single host url or an inventory module file (
*.py
). If a single host url is given without a connection schema (likessh://
), ssh will be used.
Raises
FatalError: The loaded inventory was invalid.
def loader.run_script()
loader.run_script()
def loader.run_script(script: str, frame: inspect.FrameInfo,
params: Optional[dict[str, Any]] = None,
name: Optional[str] = None) -> None:
Loads and implicitly runs the given script by creating a new instance.
Parameters
script: The path to the script that should be instanciated
frame: The FrameInfo object as given by inspect.getouterframes(inspect.currentframe())[?] where the script call originates from. Used to keep track of the script invocation stack, which helps with debugging (e.g. cyclic script calls).
name: A printable name for the script. Defaults to the script path.
Last updated