pmpy

A push-me-pull-ya client for consule + vault

Usage no npm install needed!

<script type="module">
  import pmpy from 'https://cdn.skypack.dev/pmpy';
</script>

README

NPM version"> Build Status Dependency Status

PMPY: A push-me-pull-ya client for consul + (WIP) vault

PMPY makes it easier to manage key-value data in consul. Currently get/set operations do not consider cas/ModifyIndex, etc. It simply sets or retrieves values from Consul. Both JSON and env formats for input and output.

Pushing data into Consul is as simple as:

$ pmpy consul push --path myapp --value='{"key1": "value1"}'

Pulling it back out again is just as easy:

$ pmpy consul pull --path myapp 
{
  "key1": "value1"
}

When pulling data out of Consul, PMPY allows you to specify multiple paths. The resulting document is a merged document with values specified later overriding previous values. This allows you to easily setup more complex documents to support multiple environments/applications.

For example, given these three paths:

$ pmpy consul push --path myapp/defaults --value='{"host": "foo.bar"}'
$ pmpy consul push --path myapp/prod --value='{"database": "prod_db"}'
$ pmpy consul push --path myapp/dev --value='{"database": "dev_db"}'

You can retrieve data for a specific environment by specifying mutiple paths:

$ pmpy consul pull --path myapp/defaults --path myapp/prod
{
  "host": "foo.bar",
  "database": "prod_db"
}
$ pmpy consul pull --path myapp/defaults --path myapp/prod
{
  "host": "foo.bar",
  "database": "dev_db"
}

Install

$ npm install --save pmpy

Usage

Code

var consul = require('pmpy').consul;

// prefix is options - defaults to 'pmpy'
consul({ prefix: 'myorg' })
  .pull('myapp/beta')
  .subscribe(
    (conf) => console.log(JSON.stringify(conf),
    (err)  => console.log(err.stack)
  );

CLI

$ npm install -g pmpy
$ pmpy --help

Playground

PMPY comes with a docker based playground for Consul and Vault. You will need to install the Docker tools - including compose to use it. Once you have, the playground can be managed from the cli.

pmpy playground --help
playground <action>

Commands:
  start    Start playground services
  stop     Stop playground services
  restart  Restart playground services
  reset    Resets consul & vault without a full restart
  env      Display vault keys

License

MIT © David J. Clarke