Git Product home page Git Product logo

files-to-consul-kv's Introduction

files-to-consul-kv

Simple utility for bulk loading sets of Consul key-value entries via the transactions API where the source of those values exist on disk in a directory structure.

For example given a simple directory structure like:

cd mykvs/

$ find . -print
.
./sub
./sub/key2
./key1

$ cat key1 
val1

$ cat sub/key2 
val2

You could use fs2consulkv.py to set all these in Consul under some root path:

 ./fs2consulkv.py \
    --fs-kv-path ./mykvs \
    --consul-url https://[consul-fqdn][:port] \
    --consul-acl-token xxxxxxx \
    --consul-data-center optional-dc \
    --consul-kv-root some/root/path/

Would result in your KVs in consul at:

https://[consul-fqdn][:port]/ui/mydc/kv/some/root/path/key1 = val1
https://[consul-fqdn][:port]/ui/mydc/kv/some/root/path/sub/key2 = val2

Docker

Run via Docker: https://hub.docker.com/r/bitsofinfo/files-to-consul-kv

docker run -i -v `pwd`/mykvs:/kvsource \
   bitsofinfo/files-to-consul-kv fs2consulkv.py \
   --fs-kv-path /kvsource \
   --consul-url https://[consul-fqdn][:port] \
   --consul-acl-token xxxxxxx \
   --consul-data-center optional-dc \
   --consul-kv-root some/root/path/

Usage

$ ./fs2consulkv.py  -h

usage: fs2consulkv.py [-h] [-p FS_KV_PATH] [-k CONSUL_KV_ROOT]
                      [-z CONSUL_KV_ROOT_FILE] [-c CONSUL_URL]
                      [-t CONSUL_ACL_TOKEN] [-f CONSUL_ACL_TOKEN_FILE]
                      [-d CONSUL_DATA_CENTER] [-x] [-n] [-l LOG_LEVEL]
                      [-b LOG_FILE]

optional arguments:
  -h, --help            show this help message and exit
  -p FS_KV_PATH, --fs-kv-path FS_KV_PATH
                        Full or relative path to filesystem directory
                        containing the KV structure to send to consul
                        (default: ./)
  -k CONSUL_KV_ROOT, --consul-kv-root CONSUL_KV_ROOT
                        Root path in Consul KV by which all new keys will be
                        set, required. i.e. 'some/root/path' (default: None)
  -z CONSUL_KV_ROOT_FILE, --consul-kv-root-file CONSUL_KV_ROOT_FILE
                        Path to a file that contains the consul-kv-root
                        argument value, optional, can be used instead of
                        --consul-kv-root i.e. /path/to/consul-kv-root.txt
                        where the file contents contains the value
                        'some/root/path' (default: None)
  -c CONSUL_URL, --consul-url CONSUL_URL
                        Consul url, required. i.e. http[s]://[fqdn][:port]
                        (default: None)
  -t CONSUL_ACL_TOKEN, --consul-acl-token CONSUL_ACL_TOKEN
                        Consul acl token, required (default: None)
  -f CONSUL_ACL_TOKEN_FILE, --consul-acl-token-file CONSUL_ACL_TOKEN_FILE
                        Consul acl token file, path to a file that contains
                        the token value, required (default: None)
  -d CONSUL_DATA_CENTER, --consul-data-center CONSUL_DATA_CENTER
                        Consul data-center, optional. (default: None)
  -x, --skip-prompt     Skip confirmation and prompt (default: False)
  -n, --retain-trailing-newlines
                        Retain trailing newline chars (\n) in values files and
                        do not strip them. Default behavior is to strip them
                        (default: False)
  -s SLEEP_DELAY, --sleep-delay SLEEP_DELAY
                        Delay [in seconds] in kv upload loop, to avoid
                        overwhelming the consul server. Default behavior is
                        0.000 seconds (default: 0)
  -u CHUNK_SIZE, --chunk-size CHUNK_SIZE
                        Number of KV pairs uploaded at once. Default is 64,
                        the maximum allowed. (default: 64)
  -l LOG_LEVEL, --log-level LOG_LEVEL
                        log level, DEBUG, INFO, etc (default: DEBUG)
  -b LOG_FILE, --log-file LOG_FILE
                        Path to log file; default None = STDOUT (default:
                        None)

files-to-consul-kv's People

Contributors

bitsofinfo avatar ccavello avatar jonsource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

files-to-consul-kv's Issues

License?

It is unclear to me under which license this code was released.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.