Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hashi-helper

> 安全
Open source

Disaster Recovery and Configuration Management for Consul and Vault

185 stars0 likes0 views
WebsiteGitHub

About

Disaster Recovery and Configuration Management for Consul and Vault

hashi-helper

hashi-helper is a tool meant to enable Disaster Recovery and Configuration Management for Consul and Vault clusters, by exposing configuration via a simple to use and share hcl format.

  • Requirements
  • Building
  • Configuration
  • Usage
    • Global Flags
      • --lint
      • --variable
      • --variable-file
      • --concurrency
      • --log-level
      • --config-dir
      • --config-file
      • --environment
      • --application
    • Global Commands
      • push-all
      • profile-edit
      • profile-use
    • Consul
      • consul-push-all
      • consul-push-services
      • consul-push-kv
    • vault commands
      • vault-create-token
      • vault-find-token
      • vault-list-secrets
      • vault-pull-secrets
      • vault-push-all
      • vault-push-auth
      • vault-push-mounts
      • vault-push-policies
      • vault-push-secrets
      • vault-unseal-keybase
        • Options
        • Examples
  • Templating
    • Variables
      • HCL variable file
      • YAML variable file
      • JSON variable file
    • Functions
      • consul-template compatability
      • lookup
      • lookupDefault
      • service
      • serviceWithTag
      • grantCredentials
      • grantCredentialsPolicy
      • githubAssignTeamPolicy
      • ldapAssignGroupPolicy
    • Example
  • Workflow
    • Directory Structure
    • Configuration Examples
    • Vault app secret
    • Consul app KV
    • Vault auth
    • Consul services
    • Vault mount
    • Vault mount role

Requirements

  • Go 1.11

Building

To build a binary, run the following

bash
# get this repo
go get github.com/seatgeek/hashi-helper

# go to the repo directory
cd $GOPATH/src/github.com/seatgeek/hashi-helper

# build the `hashi-helper` binary
make build

This will create a hashi-helper binary in your $GOPATH/bin directory.

Configuration

The following environment variables are required for setting configuration and keys in Consul and Vault.

  • VAULT_TOKEN environment variable (preferable a root/admin token)
  • VAULT_ADDR environment variable (example: http://127.0.0.1:8200)
  • CONSUL_ADDR_HTTP environment variable (example: http://127.0.0.1:8500)

Usage

bash
hashi-helper [--global-flags] command [--command-flags]

Global Flags

--lint

Providing this flag will make hashi-helper only process configuration, and not push any changes to Consul or Vault

This is useful for CI pipelines

--variable

A number of key=value pairs to expose as template variables during template rendering.

The flag can be repeated any number of times. The order they are provided in is also the order they are read.

--var key1=value1 --var key2=value2

--var key1=value1 --var key2=value2 --var key1=value2 - key1 will be having the value value2

Aliases: --var key=value

--variable-file

A number of files to parse and expose as template variables template rendering.

The flag can be repeated any number of times. The order they are provided in is also the order they are read.

--variable-file example/conf.hcl --variable-file example/conf.json --variable-file example/conf.yaml

Aliases: --var-file value | --varf value

--concurrency

How many parallel requests to run in parallel against remote servers

Default: 2 * CPU Cores

Environment Key: CONCURRENCY

--log-level

Debug level of debug, info, warn/warning, error, fatal, panic

Default: info

Environment Key: LOG_LEVEL

--config-dir

One or more directories to recursively scan for hcl configuration files.

The flag can be repeated any number of times. The order they are provided in is also the order they are read.

--config-dir conf.d/

--config-dir conf.d/ --config-dir shared/

Environment Key: CONFIG_DIR

--config-file

One or more hcl configuration file to parse instead of a directory

The flag can be repeated any number of times. The order they are provided in is also the order they are read.

--config-file conf.d/config.hcl

--config-file conf.d/config.hcl --config-file conf.d/another_config.hcl

Environment key: CONFIG_FILE

--environment

The environment to process configuration for

Default: all

Environment Key: ENVIRONMENT

--application

The application to process for

Default: all

Environment Key: APPLICATION

Global Commands

push-all

Push all Consul and Vault data to remote servers (same as running vault-push-all and consul-push-all)

profile-edit

Decrypt (or create), open and encrypt the secure HASHI_HELPER_PROFILE_FILE (~/.vault_profiles.pgp) file containing your vault clusters

File format is as described below, a simple yaml file

…

profile-use

Decrypt the HASHI_HELPER_PROFILE_FILE and output bash/zsh compatible commands to set VAULT_ADDR, VAULT_TOKEN, ENVIRONMENT based on the profile you selected.

Example: $(hashi-helper profile-use name_1)

Consul

consul-push-all

Push all local consul state to remote consul cluster.

consul-push-services

Push all service{} stanza to remote Consul cluster

consul-push-kv

Push all kv{} stanza to remote Consul cluster

vault commands

vault-create-token

Create a Vault token, optionally encrypt it using keybase

  • --keybase optional - can be repeated for multiple recipients, token will be encrypted for all recipients to decrypt. If omitted, token is shown in cleartext in the shell
  • --id optional - The ID of the client token. Can only be specified by a root token. Otherwise, the token ID is a randomly generated UUID.
  • --display-name optional The display name of the token. Defaults to "token".
  • --ttl optional - The TTL period of the token, provided as "1h", where hour is the largest suffix. If not provided, the token is valid for the default lease TTL, or indefinitely if the root policy is used.
  • --period optional - If specified, the token will be periodic; it will have no maximum TTL (unless an "explicit-max-ttl" is also set) but every renewal will use the given period. Requires a root/sudo token to use.
  • --orphan Will create the token as orphan
  • --policy optional - Can be repeated for each policy needed. A list of policies for the token. This must be a subset of the policies belonging to the token making the request, unless root. If not specified, defaults to all the policies of the calling token.

vault-find-token

Scan all tokens in the Vault server, optionally tokens matching certain conditions

Filter flags:

--filter-name jose will only match tokens where display name contains jose

--filter-policy root will only match tokens that have the policy root

--filter-path auth/github/login will only match tokens that have the path auth/github/login

--filter-meta-username jippi will only match tokens that have the meta[username] value jippi (GitHub auth backend injects this, as an example)

--filter-orphan will only match tokens that are orphaned

Action flags:

--delete-matches will match all tokens matching the filter flags. You will be asked to verify each token before deleting it.

vault-list-secrets

Print a list of local from conf.d/ (default) or remote secrets from Vault (--remote).

Add --detailed / DETAILED to show secret data rather than just the key names.

vault-pull-secrets

NOT IMPLEMENTED YET

Write remote Vault secrets to local disk in conf.d/

vault-push-all

Pushes all mounts, policies and secrets to a remote vault server

vault-push-auth

Write Vault auth {} stanza found in conf.d/ to remote vault server

vault-push-mounts

Mount and configure mount {} stanza found in conf.d/ to remote vault server

vault-push-policies

Write Vault policy {} stanza found in conf.d/ to remote vault server

vault-push-secrets

Write local secrets to remote Vault instance

vault-unseal-keybase

Unseal Vault using the raw unseal key from keybase / gpg init/rekey .

The command expect the raw base64encoded unseal key as env VAULT_UNSEAL_KEY or --unseal-key CLI argument

It basically automates echo "$VAULT_UNSEAL_KEY" | base64 -D | keybase pgp decrypt | xargs vault unseal -address http://:8200

Options
  • --unseal-key/ VAULT_UNSEAL_KEY (default: ``) The raw base64encoded unseal key as env or CLI argument
  • --consul-service-name / CONSUL_SERVICE_NAME (default: ``) If specified, the tool will try to lookup all vault servers in the configured Consul catalog and unseal all of them. This is the service name, e.g. vault
  • --consul-service-tag / CONSUL_SERVICE_TAG (default: standby) The Consul catalog tag to filter vault instances from if CONSUL_SERVICE_NAME is used.
  • --vault-protocol / VAULT_PROTOCOL (default: http) The protocol to use when constructing the VAULT_ADDR value when using CONSUL_SERVICE_NAME unseal strategy.

All VAULT_* env keys are preserved when using CONSUL_SERVICE_TAG, address is the only field being overwritten per vault instance found in the catalog. So you can still configure TLS and other Vault changes as usual with the environment.

Examples
  • VAULT_UNSEAL_KEY=$token hashi-helper vault-unseal-keybase
  • hashi-helper vault-unseal-keybase --unseal-key=$key
  • VAULT_CONSUL_SERVICE=vault VAULT_UNSEAL_KEY=$token hashi-helper vault-unseal-keybase
  • hashi-helper vault-unseal-keybase --unseal-key=$key --consul-service-name vault

Templating

hashi-helper version >= 2.0 support templating for configuration files.

All configuration files loaded are automatically rendered as a template using go text/template.

This is identical to how hashicorp/consul-template renders content.

Templates use [[ ]] brackes instead of the default {{ }} style to avoid clashes with HCL { } stanza definitions.

Variables

You can provide variables for templating through the CLI in various ways. All of these options can be provided any number of times

--variable-file or --var-file

--variable key=value or --var key=value

The tool can load files with extensions .hcl, .yaml/.yml and .json. Variables are loaded in the order they are provided in CLI, so it's possible to cascade / overwrite configuration files by using a specific loading order. --variable-file are loaded before CLI --variable key=value arguments.

HCL variable file

hcl
consul_domain    = "consul"
environment_name = "staging"
environment_tld  = "stag"
db_default_ttl   = "9h"
db_max_ttl       = "72h"
my_key           = "hello world"

# a list of things

stuff = ["a", "b", "c"]

here_doc = <<-DOC
  something multiline
  that will be available
  as a single string
  D

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goconfiguration-managementconsulconsul-servicedisaster-recovery

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.