class genvid.toolbox.ConsulTemplate(executable: Optional[Union[Path, str]] = None)

Bases: object

Thin wrapper API around consul-template.

class OptionKind(value)

Bases: Enum

Used to describe the different options to consul-template.

This is necessary as some of the assumptions made by this wrapper must be enforced at the option level. The following description exists:

  • FLAG - The option is supported as a flag (without value).

  • TAKES_VALUE - The option is supported and requires a value.

  • DISABLED - The option cannot be used directly.

FLAG = 0
property executable

consul-template binary location.

property version

Retrieve the version string of consul-template --version.

This is the only way to retrieve the version through this API as the option is disabled on all other methods.

once(*, env: Optional[Mapping[str, str]] = None, **kwargs) ConsulTemplateOutput

Execute consul-template in non-daemon form.

consul-template will be started in a subprocess with the --once option appended automatically. The exact behavior will depend on the options passed to kwargs (you can check the -h of consul-template for more information about the command).

  • 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.


    The script will automatically convert all key/values into strings.

  • kwargs

    Any parameters recognized by consul-template and not marked as ConsulTemplate.OptionKind.DISABLED.

    See also

    The output of consul-template -h for an exhaustive list of all supported options. The once option is added automatically and therefore should not be added again in the argument. The other option not accepted is version.


A ConsulTemplateOutput object holding the state returned following execution of consul-template.

New in version 1.22.0.

class consul_template.ConsulTemplate

Implementation of genvid.toolbox.ConsulTemplate