Etcdist
This is a small gem that helps you manage your etcd keys and values in a way that's easy to version control.
Installation
Add this line to your application's Gemfile:
gem 'etcdist'
And then execute:
bundle
Or install it yourself as:
gem install etcdist
Usage
Create the data
Create your desired directory structure. This will be replicated in etcd. For example:
mkdir -p data/foo/bar
Then create a file in the leaf directory containing the keys and values that you want to go into etcd. For example:
cat <<EOT > data/foo/bar/food.data
fish=plankton
cows=grass
EOT
The name of the file containing the keys and values doesn't matter. In fact, you can split the data into multiple files, if you want. An example would look like:
./data
└── ./foo
└── ./bar
├── food.data # contains fish=plankton and cows=grass
└── more.data # could contain more keys and values
Populate etcd
Then pass the path to your data directory to Etcdist. For example:
#!/usr/bin/env ruby
require 'etcdist'
Etcdist.execute('data')
If you want Etcdist to remove data from etcd that is no longer in your data files, use dangerous
mode:
Etcdist.execute('data', dangerous: true)
If you just want to perform a trial run without making any changes, then use the dry_run
mode:
Etcdist.execute('data', dangerous: true, dry_run: true)
Configuration
Etcd host
Etcdist.execute(dir) # defaults to localhost:4001
Etcdist.execute(dir, host: '127.0.0.1', port: 4003)
Log level
You can control the log level, as follows:
Etcdist::Log.level = :info
Get Involved
Mailing List
Use the etcdist mailing list to get in touch with other users and developers.
Developing
Clone the source code. To see what's possible, run:
rake -T
To get the acceptance test to pass, make sure you've got etcd running locally:
docker run -d -p 4001:4001 coreos/etcd
To continuously run tests, run:
guard
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request