Skip to main content

Code to configure consul key:value store for applications

Project description

Use Consulconf to get or set key:value data from json files or consul.

This tool supports the concept of inheritance, where one namespace of
key:value pairs can inherit one or more keys from another namespace.
This is particularly useful if, for instance, you wish to manage
environment variables for several applications that may share certain
variables in common. Currently, though, parent namespaces (ie any
namespace with children) cannot inherit from other namespaces. It may
be worth changing this behavior if someone can come up with a good

You don't necessarily need consul to use this tool.


pip install consulconf


basic usage
consulconf -h

mkdir json_files

# basic examples
echo '{"MYVAR": "123", "OTHERVAR": 456}' > ./json_files/namespace.json
consulconf -i ./json_files --dry_run
consulconf -i ./json_files --app namespace env
consulconf -i ./json_files --app namespace echo \$MYVAR

# namespace filtering
echo '{"app1": {"AVAR": 1}, "app2": {"AVAR": 2}}' > ./json_files/apps.json
consulconf -i ./json_files --dry_run
consulconf -i ./json_files --dry_run --filterns '^apps/.*[12]$'

# inheritance
echo '{"_inherit": ["namespace.MYVAR"], "nines": 999}' > ./json_files/ns2.json
consulconf -i ./json_files --dry_run --filterns 'ns2'
consulconf -i ./json_files --app ns2 env

# push namespaces to consul (you need to have a consul agent installed)
consulconf -i ./json_files -p

# get namespaces from consul
consulconf -i --dry_run
consulconf -i --app ns2 env

Additionally, you can use this tool to raw copy the contents of json
files into consul. If you run the below commands and then navigate to
consul, you will see the data in your json files copied to consul.

consulconf -i ./json_files --dry_run --raw
consulconf -i ./json_files -p --raw
consulconf -i --dry_run --raw

NOTE: Some of the examples above assume a consul agent is running on
your computer. To get consul working, you could run something like:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date (11.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page