Giter Club home page Giter Club logo

etcdtool's Introduction

etcdtool

Export/Import/Edit etcd directory as JSON/YAML/TOML and validate directory using JSON schema.

Use cases

  • Backup/Restore in a format which is not database or version specific.
  • Migration of data from production to testing.
  • Store configuration in Git and use import to populate etcd.
  • Validate directory entries using JSON schema.

Build

git clone https://github.com/mickep76/etcdtool.git
cd etcdtool
make

Build RPM

Make sure you have Docker configured.

git clone https://github.com/mickep76/etcdtool.git
cd etcdtool
make rpm

Install using Homebrew on Mac OS X

brew tap mickep76/funk-gnarge
brew install etcdtool

Update

brew update
brew upgrade --all

Example

Make sure you have Docker configured.

Start etcd:

./init-etcd.sh start
eval "$(./init-etcd.sh env)"

Import some data:

cd examples/host/
etcdtool import /hosts/test1.example.com test1.example.com.json
etcdtool import /hosts/test2.example.com test2.example.com.json

Inspect the content:

etcdtool tree /
etcdtool export /

Validate data with different routes:

etcdtool -d -c etcdtool.toml validate /
etcdtool -d -c etcdtool.toml validate /hosts
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com/interfaces
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com/interfaces/eth0

Import with validation:

etcdtool -d -c etcdtool.toml import -v /hosts/test3.example.com test2.example.com.json

Fix validation error:

etcdtool -d -c etcdtool.toml edit -v -f toml /hosts/test2.example.com
---
    gw = "1.192.168.0.1"
+++
    gw = "192.168.0.1"

Re-validate data:

etcdtool -d -c etcdtool.toml validate /hosts

Authentication

These commands will prompt you for the password for the user. Alternatively, you can pass the password in a file with --password-file or -F:

cat /path/to/passwordfile
passwordstring

etcdtool -password-file /path/to/passwordfile validate /hosts

Caveats

  • etcd doesn't support list's, this is handled by using the index as the key:

JSON Input:

{
    "users": [
        { "username": "jblack", "first_name": "John", "last_name": "Blackbeard" },
        { "username": "ltrier", "first_name": "Lars", "last_name": "Von Trier" }
    ]
}

Result in etcd:

users/0/username: jblack
users/0/first_name: John
users/0/last_name: Blackbeard
users/1/username: ltrier
users/1/first_name: Ludwig
users/1/last_name: Von Treimer

TODO

  • Add detection of format for import based on file type

etcdtool's People

Contributors

davewalk avatar roscopecoltran avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.