class genvid.toolbox.ConsulTemplateTool(**kwargs)

Bases: VaultTool

Wrapper around ConsulTemplate to integrate with the toolbox.

The API defined by this class offer parameters to seemlessly integrate with Consul and Vault while giving full flexibility to the user to customize the underlying consul-template invocations.

Changed in version 1.22.0:

  • Rewrote the API to make it stable enough for wide-spread usage.

  • Now using ConsulTemplate under the hood.

property consul_template

Access the underlying ConsulTemplate instance.

The ConsulTemplate instance is lazily instantiated on the first invocation.


ExecutableNotInPathError – If the tool was unable to find an executable for consul-template.


This method can only raise an exception on its first invocation. Subsequent invocations are guaranteed not to raise anything.

consul_template_once(*, use_consul: bool = False, use_vault: bool = False, env: Optional[Mapping[str, str]] = None, **kwargs) ConsulTemplateOutput

Invoke consul-template in non-daemon mode.

  • use_consul

    Customize consul-template invocation so that it is able to send requests to Consul.


    This is accomplished by setting consul_addr automatically.

  • use_vault

    Customize consul-template invocation so that it is able to send requests to Vault.


    This is accomplished by setting vault-token and vault-renew-token automatically.

  • env – If provided, will run the subprocess with the provided environment. This is particularly useful if the template depends on a lot on environment variables.

  • kwargs

    Options to pass to consul-template directly.


    User-specified options will always take precedence on the value set by this tool to have consul and vault work properly.

    See also

    ConsulTemplate for more information on the supported options.


Any exception defined by ConsulTemplate.once(). Some Vault-related exceptions may also be thrown if use_vault is set to True.


The ConsulTemplateOutput returned by the invocation of ConsulTemplate.once().

load_config_template(template: Union[Path, str], env: Optional[Mapping[str, str]] = None) Any

Load a configuration template file.

Render a configuration template file using consul-template and returns it as a dictionary.

New in version 1.29.0.

class consul_template.ConsulTemplateTool

Implementation of genvid.toolbox.ConsulTemplateTool