genvid.toolbox.ConsulTemplateTool

class genvid.toolbox.ConsulTemplateTool(**kwargs)

Bases: genvid.toolbox.vault.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.

consul_template

Access the underlying ConsulTemplate instance.

The ConsulTemplate instance is lazily instantiated on the first invocation.

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

Note

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: typing.Union[typing.Mapping[str, str], NoneType] = None, **kwargs) → genvid.toolbox.consul_template.ConsulTemplateOutput

Invoke consul-template in non-daemon mode.

Parameters:
  • use_consul

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

    Important

    This is accomplished by setting consul_addr automatically.

  • use_vault

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

    Important

    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.

    Important

    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.

Raises:

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

Returns:

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

load_config_template(template: typing.Union[pathlib.Path, str], env: typing.Union[typing.Mapping[str, str], NoneType] = None) → typing.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