Erlang Config Layer. eclair is an escript that merges Erlang config stored in a well-defined hierarchy of S3 paths.
These steps will get eclair set up to pull config from an S3 path.
make build
cp eclair.tar ~/path/to/myapp && cd ~/path/to/myapp
tar xfv eclair.tar
./eclair.erl bootstrap -version auto
Note: Your S3 credentials will be stored in .eclair/secure.config
.
eclair is able to merge together standard Erlang proplist config files. Here's an example:
[
{myapp, [
{config_item, "Hi!"}
]}
].
We'll consider this file our root config and upload it to
s3://${ECLAIR_ROOT}/myapp/root/myapp.config
.
Next, our app has a config element specific to a QA environment.
We'll upload the following files to
s3://${ECLAIR_ROOT}/myapp/env/qa/myapp.config
.
[
{myapp, [
{password, "myQApassword"}
]}
].
And PROD config to
s3://${ECLAIR_ROOT}/myapp/env/pro/myapp.config
.
[
{myapp, [
{password, "myPRODpassword"}
]}
].
When myapp
is deployed, the deploy script must run
./eclair.erl -tags env/qa
The final config will contain this data:
[
{myapp, [
{config_item, "Hi!"},
{password, "myQApassword"}
]}
].
The bootstrap step is optionally run to help the user set up the necessary eclair config. Most
importantly this is the s3 access_key
and secret_key
. It's exercisted with ./eclair.erl bootstreap
,
and command line arguments can be given (e.g. -version 1.0.1
)
- Read command line arguments
- Read from
.eclair/secure.config
- Read from
~/.s3cfg
(access_key
andsecret_key
only) - Read from input prompt
- Write
.eclair/secure.config
This represents the main operation of eclair. It's exercised with ./eclair.erl
, and
command line arguments can be given to override anything in .eclair/secure.config
.
- Read command lien arguments
- Read from
.eclair/secure.config
- Read from hardcoded values in
eclair.erl
macros
- Get list of nodes from epmd
- Get hostname
- Find application details in an
ebin/*.app
file
- Append application name from
*.app
file to eclair root - List s3 common prefixes for the
version
subkey - Find existing version-root that is closest to the version input. (if none, this step is skipped)
- Search for config with these subkeys:
root
,input/tag1
,input/tag2
,epmd/node1
,epmd/node2
,host/this-host
- List all keys at this path
- Create subdirectories as needed
- If new file,
get
the file directly - If existing file, attempt a
file:consult
on both, and merge - If
consult
fails, overwrite existing file
The release command does everything that the main does, but will search for the existence of releases/RELEASES to aid in the search for the app's root directory. If releases/RELEASES does not exist, then the current directory of eclair.erl is considered the root.