cmdb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +86 -0
- data/README.md +250 -0
- data/Rakefile +17 -0
- data/TODO.md +3 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/cmdb.gemspec +22 -0
- data/fixtures/Gemfile +4 -0
- data/fixtures/Gemfile.lock +19 -0
- data/fixtures/app/widgets.rb +4 -0
- data/fixtures/config.ru +29 -0
- data/lib/cmdb.rb +2 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9212599111d82e3f236f06fb05aaf87ec0932155
|
4
|
+
data.tar.gz: 87200c6133a80e8f2bd02f02697aa0d42c694622
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86b209d6f11b166e981cd7a0eeac50f10a78a8efa5ef4db7c973642c4eb26aa519741b7ffbdbb3e1e266f794e9429c19fb646bdddb749ae18cdd0429f4fc3fa6
|
7
|
+
data.tar.gz: 33d7b4855c49ece993167e1dbfd7da504a337fae128a60096d037fcaa51f8b0815658b2ac2ffb32d1875563464b16e1447a85316429dc0d08a0e0c760fbf48e0
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# simplecov/rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
pkg
|
15
|
+
|
16
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
17
|
+
#
|
18
|
+
# * Create a file at ~/.gitignore
|
19
|
+
# * Include files you want ignored
|
20
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
21
|
+
#
|
22
|
+
# After doing this, these files will be ignored in all your git projects,
|
23
|
+
# saving you from having to 'pollute' every project you touch with them
|
24
|
+
#
|
25
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
26
|
+
#
|
27
|
+
# For MacOS:
|
28
|
+
#
|
29
|
+
.DS_Store
|
30
|
+
|
31
|
+
# for IntelliJ, RubyMine
|
32
|
+
.idea
|
33
|
+
|
34
|
+
# For TextMate
|
35
|
+
#*.tmproj
|
36
|
+
#tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
#*~
|
40
|
+
#\#*
|
41
|
+
#.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
#*.swp
|
45
|
+
|
46
|
+
# For redcar:
|
47
|
+
#.redcar
|
48
|
+
|
49
|
+
# For rubinius:
|
50
|
+
#*.rbc
|
51
|
+
.rvmrc
|
52
|
+
.ruby-gemset
|
53
|
+
.ruby-version
|
54
|
+
|
55
|
+
# For IntelliJ/RubyMine
|
56
|
+
.idea/*
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.1
|
5
|
+
bundler_args: --without development
|
6
|
+
before_install:
|
7
|
+
- gem install --no-document -v '~> 1.10' bundler
|
8
|
+
before_script:
|
9
|
+
- bundle install
|
10
|
+
script:
|
11
|
+
- bundle exec rake ci:spec
|
12
|
+
- bundle exec rake ci:cucumber
|
13
|
+
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
### 2.6.0 (2016-03-01)
|
2
|
+
|
3
|
+
Two new command line options are added to the shim
|
4
|
+
`--consul-url` = The URL of the consul agent. Example: http://consul:8500
|
5
|
+
`--consul-prefix` = The prefix to use when getting keys from consul. Example: shard403
|
6
|
+
|
7
|
+
There are two ways of using the shim.
|
8
|
+
|
9
|
+
1. Using to replace keys in legacy ruby apps:
|
10
|
+
---------------------------------------------
|
11
|
+
|
12
|
+
When using the shim to replace keys in configuration files, it is sufficient to specify
|
13
|
+
the shard identifier (shard403, shard93, etc) as the prefix. Also prefix is optional so
|
14
|
+
in dev environments if you don't have these shard identifier as prefixes, you don't have
|
15
|
+
to specify it. When replacing keys in configuration files, the requested keys are loaded
|
16
|
+
from consul on demand.
|
17
|
+
|
18
|
+
Example:
|
19
|
+
```
|
20
|
+
bundle exec cmdb shim --consul-url=http://consul:8500 --consul-prefix=shard403 \
|
21
|
+
--dir=config -- rainbows -c config/rainbows.rb
|
22
|
+
```
|
23
|
+
|
24
|
+
2. Using to populate environment in modern apps:
|
25
|
+
------------------------------------------------
|
26
|
+
|
27
|
+
The --consul-prefix command line option can be specifed multiple times just like the
|
28
|
+
envconsul tool allows and all keys under the specified prefix are loaded in the
|
29
|
+
environment and the prefix itself is skipped.
|
30
|
+
|
31
|
+
Example:
|
32
|
+
```
|
33
|
+
bundle exec cmdb shim --consul-url=http://consul:8500 --consul-prefix=shard403/common \
|
34
|
+
--consul-prefix=shard403/cwf_public_service --env -- rainbows -c config/rainbows.rb
|
35
|
+
```
|
36
|
+
|
37
|
+
### 2.5.0 (2015-07-16)
|
38
|
+
|
39
|
+
So many changes! View the diffs for info.
|
40
|
+
|
41
|
+
### 2.1.0
|
42
|
+
|
43
|
+
Initial release. Contains the following features:
|
44
|
+
- API for querying a CMDB
|
45
|
+
- Command-line shim for rewriting config files
|
46
|
+
- Server restart feature to aid debugging
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cmdb (0.1.0)
|
5
|
+
diplomat (~> 0.15)
|
6
|
+
listen (~> 3.0)
|
7
|
+
trollop (~> 2.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
backticks (0.4.0)
|
13
|
+
builder (3.2.2)
|
14
|
+
byebug (8.2.2)
|
15
|
+
coderay (1.1.1)
|
16
|
+
cucumber (2.3.2)
|
17
|
+
builder (>= 2.1.2)
|
18
|
+
cucumber-core (~> 1.4.0)
|
19
|
+
cucumber-wire (~> 0.0.1)
|
20
|
+
diff-lcs (>= 1.1.3)
|
21
|
+
gherkin (~> 3.2.0)
|
22
|
+
multi_json (>= 1.7.5, < 2.0)
|
23
|
+
multi_test (>= 0.1.2)
|
24
|
+
cucumber-core (1.4.0)
|
25
|
+
gherkin (~> 3.2.0)
|
26
|
+
cucumber-wire (0.0.1)
|
27
|
+
diff-lcs (1.2.5)
|
28
|
+
diplomat (0.15.0)
|
29
|
+
faraday (~> 0.9)
|
30
|
+
json (~> 1.8)
|
31
|
+
faraday (0.9.2)
|
32
|
+
multipart-post (>= 1.2, < 3)
|
33
|
+
ffi (1.9.10)
|
34
|
+
gherkin (3.2.0)
|
35
|
+
json (1.8.3)
|
36
|
+
listen (3.0.6)
|
37
|
+
rb-fsevent (>= 0.9.3)
|
38
|
+
rb-inotify (>= 0.9.7)
|
39
|
+
method_source (0.8.2)
|
40
|
+
multi_json (1.11.2)
|
41
|
+
multi_test (0.1.2)
|
42
|
+
multipart-post (2.0.0)
|
43
|
+
pry (0.10.3)
|
44
|
+
coderay (~> 1.1.0)
|
45
|
+
method_source (~> 0.8.1)
|
46
|
+
slop (~> 3.4)
|
47
|
+
pry-byebug (3.3.0)
|
48
|
+
byebug (~> 8.0)
|
49
|
+
pry (~> 0.10)
|
50
|
+
rake (10.5.0)
|
51
|
+
rb-fsevent (0.9.7)
|
52
|
+
rb-inotify (0.9.7)
|
53
|
+
ffi (>= 0.5.0)
|
54
|
+
rspec (3.4.0)
|
55
|
+
rspec-core (~> 3.4.0)
|
56
|
+
rspec-expectations (~> 3.4.0)
|
57
|
+
rspec-mocks (~> 3.4.0)
|
58
|
+
rspec-core (3.4.3)
|
59
|
+
rspec-support (~> 3.4.0)
|
60
|
+
rspec-expectations (3.4.0)
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
+
rspec-support (~> 3.4.0)
|
63
|
+
rspec-mocks (3.4.1)
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
+
rspec-support (~> 3.4.0)
|
66
|
+
rspec-support (3.4.1)
|
67
|
+
slop (3.6.0)
|
68
|
+
trollop (2.1.2)
|
69
|
+
yard (0.8.7.6)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
backticks
|
76
|
+
bundler (~> 1.10)
|
77
|
+
cmdb!
|
78
|
+
cucumber
|
79
|
+
pry
|
80
|
+
pry-byebug
|
81
|
+
rake
|
82
|
+
rspec
|
83
|
+
yard
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
# CMDB
|
2
|
+
|
3
|
+
[![TravisCI][travis_ci_img]](https://magnum.travis-ci.com/rightscale/cmdb)
|
4
|
+
[travis_ci_img]: https://magnum.travis-ci.com/rightscale/cmdb.svg?token=ETyVMY7RGypDf6U8z6jc&branch=master
|
5
|
+
|
6
|
+
CMDB is a Ruby interface for consuming data from one or more configuration management databases
|
7
|
+
(CMDBs). It is intended to support multiple CM technologies, including:
|
8
|
+
- JSON/YAML files on a local disk
|
9
|
+
- consul
|
10
|
+
- (someday) etcd
|
11
|
+
- (someday) ZooKeeper
|
12
|
+
|
13
|
+
The CMDB's command-line tool can also facilitate debugging by watching your application's files
|
14
|
+
and sending SIGHUP (or the signal of your choice) to the app server if anything changes.
|
15
|
+
|
16
|
+
Maintained by
|
17
|
+
- [RightScale Inc.](https://www.rightscale.com)
|
18
|
+
|
19
|
+
## Why should I use this gem?
|
20
|
+
|
21
|
+
By using a standardized API for querying inputs, your application is decoupled from the underlying
|
22
|
+
configuration management database that our Operations team is using. Today we happen to use JSON
|
23
|
+
files that live under /etc/rightscale, but tomorrow we might use a key/value store such as etcd or
|
24
|
+
consul (possibly in combination with flat files). This gem will deal with all of that complexity
|
25
|
+
and provide you with a simple interface for reading your app's configuration.
|
26
|
+
|
27
|
+
The gem has two primary interfaces:
|
28
|
+
- The `cmdb shim` command populates the environment with config data and/or rewrites hardcoded
|
29
|
+
config files, then spawns your application. It can also be told to watch the filesystem for changes and
|
30
|
+
send a signal e.g. `SIGHUP` to your application, bringing reload-on-edit functionality to any app.
|
31
|
+
- The `CMDB::Interface` object provides a programmatic API for querying configuration. Its `#to_h`
|
32
|
+
method transforms the whole configuration into an environment-friendly hash if you prefer to seed the
|
33
|
+
environment yourself.
|
34
|
+
|
35
|
+
The CMDB gem is friendly to 12-factor and "Rails-style" apps and can be used with or without the shim,
|
36
|
+
depending on your application's needs.
|
37
|
+
|
38
|
+
# Getting Started
|
39
|
+
|
40
|
+
## Create CMDB Data Files
|
41
|
+
|
42
|
+
The shim looks in two locations to find data files. In order of precedence:
|
43
|
+
1. `/var/lib/cmdb` -- typically used at deployment time
|
44
|
+
2. `~/.cmdb` -- useful for developers when testing the app
|
45
|
+
|
46
|
+
The base name (minus extension) of each file is important; it determines the top-level name of
|
47
|
+
the keys in that file and it *must be unique* across all of the directories. For instance,
|
48
|
+
`my_app.json` defines CMDB keys in the `my_app.*` hierarchy.
|
49
|
+
|
50
|
+
Create a data file in one of these directories; for example, you might create `my_app.yml` with
|
51
|
+
the following contents:
|
52
|
+
|
53
|
+
db:
|
54
|
+
hostname: db1.local
|
55
|
+
widgets:
|
56
|
+
flavors:
|
57
|
+
- vanilla
|
58
|
+
- chocolate
|
59
|
+
|
60
|
+
## Invoke the CMDB Shim
|
61
|
+
|
62
|
+
For non-Ruby applications, or for situations where CMDB values are required
|
63
|
+
outside of the context of interpreted code, use `cmdb shim` to run
|
64
|
+
your application. The shim can do several things for you:
|
65
|
+
|
66
|
+
1. Make CMDB values available to your app (in `ENV`, or by rewriting files)
|
67
|
+
2. Change the user before invoking your app (e.g. drop privileges to `www-data`)
|
68
|
+
3. Watch for filesystem changes and reload your app on demand
|
69
|
+
|
70
|
+
### Populate the environment for a dotenv-compatible application
|
71
|
+
|
72
|
+
If you have an app that uses 12-factor (dotenv) style configuration, the shim
|
73
|
+
can populate the environment with CMDB values:
|
74
|
+
|
75
|
+
bundle exec cmdb shim --env
|
76
|
+
|
77
|
+
# Now your app can refer to ENV['DB_HOSTNAME'] or ENV['WIDGETS_FLAVORS]
|
78
|
+
# Note missing "my_app" prefix that would be present if you asked for these using their CMDB key names
|
79
|
+
|
80
|
+
Note that the data type of CMDB inputs is preserved: lists remain lists, numbers remain numbers,
|
81
|
+
and so forth. This works irrespective of the format of your configuration files, and also holds true
|
82
|
+
for CMDB values that are serialized to the environment (as a JSON document, in the case of lists).
|
83
|
+
|
84
|
+
### Rewriting configuration files with CMDB values
|
85
|
+
|
86
|
+
If the `--dir` option is provided, the shim recursively scans your working
|
87
|
+
directory (`Dir.pwd`) for data files that contain replacement tokens; when a token is
|
88
|
+
found, it substitutes the corresponding CMDB key's value.
|
89
|
+
|
90
|
+
Replacement tokens look like this: `<<name.of.my.key>>` and can appear anywhere in a file as a YAML
|
91
|
+
or JSON _value_ (but never a key).
|
92
|
+
|
93
|
+
Replacement tokens should appear inside string literals in your configuration files so they don't
|
94
|
+
invalidate syntax or render the files unparsable by other tools.
|
95
|
+
|
96
|
+
The shim performs replacement in-memory and saves all of the edits at once, making the rewrite
|
97
|
+
operation nearly atomic. If any keys are missing, then no files are changed on disk and the shim
|
98
|
+
exits with a helpful error message.
|
99
|
+
|
100
|
+
*NOTE:* the shim does not perform rewriting in development mode; the expectation is that your app's
|
101
|
+
configuration files will already provide reasonable dev-mode defaults and that rewriting them
|
102
|
+
is not necessary.
|
103
|
+
|
104
|
+
Given `my_app.yml` and an application with two configuration files:
|
105
|
+
|
106
|
+
# config/database.yml
|
107
|
+
production:
|
108
|
+
host: <<my_app.db.hostname>
|
109
|
+
database: my_app_production
|
110
|
+
|
111
|
+
# config/widgets.json
|
112
|
+
{'widgetFlavors': '<<my_app.widgets.flavors>>'}
|
113
|
+
|
114
|
+
I can run the following command in my application's root directory:
|
115
|
+
|
116
|
+
bundle exec cmdb shim --dir=config rackup
|
117
|
+
|
118
|
+
This will rewrite the files under config, replacing my configuration files as
|
119
|
+
follows:
|
120
|
+
|
121
|
+
# config/database.yml
|
122
|
+
production:
|
123
|
+
host: db1.local
|
124
|
+
database: my_app_production
|
125
|
+
|
126
|
+
# config/widgets.json
|
127
|
+
{'widgetFlavors':['vanilla', 'chocolate']}
|
128
|
+
|
129
|
+
### Drop Privileges
|
130
|
+
|
131
|
+
If your app doesn't know how to safely switch to a non-privileged user, the shim
|
132
|
+
can do this for you. Just add the `--user` flag when you invoke it:
|
133
|
+
|
134
|
+
bundle exec cmdb shim --user=www-data whoami
|
135
|
+
|
136
|
+
### Reload the App When Code Changes
|
137
|
+
|
138
|
+
You can pass the `--reload=key.name` option to `cmdb shim` in order to enable filesystem
|
139
|
+
watching. The shim will signal your application server whenever files are created,
|
140
|
+
updated or deleted, generally causing a graceful restart of the server process.
|
141
|
+
|
142
|
+
Needless to say, your app server must support graceful restart upon receipt of
|
143
|
+
a certain signal! The CMDB gem uses SIGHUP by default, but you can override this
|
144
|
+
with --reload-signal=SIGWHATEVER.
|
145
|
+
|
146
|
+
The parameter names a CMDB key (such as `key.name`) whose value determines whether filesystem
|
147
|
+
watching is enabled. It *should* be a boolean, but *may* be nil or any "truthy" value such as a
|
148
|
+
number or string. If the key is truthy, then the shim will perform filesystem-watching.
|
149
|
+
|
150
|
+
## Query the CMDB Directly
|
151
|
+
|
152
|
+
Ruby applications can access the CMDB as a Ruby proxy object:
|
153
|
+
|
154
|
+
# Ready to use; no bootstrapping required.
|
155
|
+
require 'cmdb'
|
156
|
+
|
157
|
+
cmdb = CMDB::Interface.new
|
158
|
+
cmdb.get('my_app.my_setting')
|
159
|
+
cmdb.get('my_app.some_other_setting')
|
160
|
+
|
161
|
+
This allows you to read CMDB values from the directly from your code.
|
162
|
+
|
163
|
+
# Data Model
|
164
|
+
|
165
|
+
This library models all CMDBs as hierarchical key/value stores whose leaf nodes can be strings,
|
166
|
+
numbers, or arrays of like-typed objects. This model is a "least common denominator" simplification
|
167
|
+
of the data models of YML, JSON, ZooKeeper and etcd, allowing all of those technologies to be
|
168
|
+
treated as interchangeable sources of configuration information.
|
169
|
+
|
170
|
+
CMDB key names consist of a dot-separated string e.g. `my_app.category_of_settings.some_value`. The
|
171
|
+
value of a CMDB key can be a string, boolean, number, nil, or a list of any of those types.
|
172
|
+
|
173
|
+
CMDB keys *cannot* contain maps/hashes, nor can lists contain differently-typed data.
|
174
|
+
|
175
|
+
## Disk-Based Data Sources
|
176
|
+
|
177
|
+
When the CMDB interface is initialized, it searches two directories for YAML files:
|
178
|
+
- /var/lib/cmdb
|
179
|
+
- ~/.cmdb
|
180
|
+
|
181
|
+
YAML files in these directories are assumed to contain CMDB values and loaded into memory in the
|
182
|
+
order they are encountered. The hierarchy of the YAML keys is flattened in order to derive
|
183
|
+
dot-separated key names. Consider the following YAML file:
|
184
|
+
|
185
|
+
# beverages.yml
|
186
|
+
coffee:
|
187
|
+
- latte
|
188
|
+
- cappucino
|
189
|
+
- mocha
|
190
|
+
- macchiato
|
191
|
+
tea:
|
192
|
+
- chai
|
193
|
+
- herbal
|
194
|
+
- black
|
195
|
+
to_go: true
|
196
|
+
|
197
|
+
This defines three CMDB values: `beverages.coffee` (a list of four items), `beverages.tea`
|
198
|
+
(a list of three items), and `beverages.to_go` (a boolean).
|
199
|
+
|
200
|
+
### Key Namespaces
|
201
|
+
|
202
|
+
The name of a CMDB file is important; it defines a namespace for all of the variables contained
|
203
|
+
inside. No two files may share a name; therefore, no two CMDB keys can have the same name.
|
204
|
+
Likewise, all keys with a given prefix are guaranteed to come from the same source.
|
205
|
+
|
206
|
+
### Overlapping Namespaces
|
207
|
+
|
208
|
+
Because CMDB files can come from several directories, it's possible for two same-named data files
|
209
|
+
to define values in the same namespace. In this case, the behavior of RightService varies depending
|
210
|
+
on the value of RACK_ENV or RAILS_ENV:
|
211
|
+
|
212
|
+
- unset, development or test: CMDB chooses the highest-precedence file and ignores the others
|
213
|
+
after printing a warning. Files in `/etc` win over files in `$HOME`, which win over
|
214
|
+
files in the working directory.
|
215
|
+
|
216
|
+
- any other environment: CMDB fails with an error message that describes the problem and
|
217
|
+
the locations of the overlapping files.
|
218
|
+
|
219
|
+
### Ambiguous Key Names
|
220
|
+
|
221
|
+
Consider a file that defines the following variables:
|
222
|
+
|
223
|
+
# confusing.yml
|
224
|
+
this:
|
225
|
+
is:
|
226
|
+
ambiguous
|
227
|
+
was:
|
228
|
+
very: ambiguous
|
229
|
+
extremely: confusing
|
230
|
+
|
231
|
+
At first glance, ths file defines two CMDB keys:
|
232
|
+
- `confusing.this.is` (a string)
|
233
|
+
- `confusing.this.was` (a map)
|
234
|
+
|
235
|
+
However, an equally valid interpretation would be:
|
236
|
+
- `confusing.this.is`
|
237
|
+
- `confusing.this.was.very`
|
238
|
+
- `confusing.this.was.extremely`
|
239
|
+
|
240
|
+
Because CMDB keys cannot contain maps, the first interpretation is wrong. The second
|
241
|
+
interpretation is valid according to the data model, but results in a situation where the type
|
242
|
+
of the keys could change if the structure of the YML file changes.
|
243
|
+
|
244
|
+
For this reason, any YAML file that defines an "ambiguous" key name will cause an error at
|
245
|
+
initialization time. To avoid ambiguous key names, think of your YAML file as a tree and remember
|
246
|
+
that _leaf nodes must define data_ and _internal nodes must define structure_.
|
247
|
+
|
248
|
+
## Network Data Sources
|
249
|
+
|
250
|
+
TODO: add support for etcd or similar
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
|
7
|
+
require 'cucumber/rake/task'
|
8
|
+
desc "Run functional tests"
|
9
|
+
Cucumber::Rake::Task.new do |t|
|
10
|
+
t.cucumber_opts = %w{--color --format pretty}
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rspec/core'
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
|
17
|
+
task :default => [:spec, :cucumber]
|
data/TODO.md
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/cmdb.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'cmdb'
|
3
|
+
spec.version = '0.1.0'
|
4
|
+
spec.authors = ['RightScale']
|
5
|
+
spec.email = ['rubygems@rightscale.com']
|
6
|
+
|
7
|
+
spec.summary = %q{Command-line tool for configuration manegement databases}
|
8
|
+
spec.description = %q{Reads CMDB variables from files, Consul, and elsewhere.}
|
9
|
+
spec.homepage = 'https://github.com/rightscale/cmdb'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
13
|
+
spec.require_paths = ['lib']
|
14
|
+
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new("~> 2.0")
|
16
|
+
|
17
|
+
spec.add_dependency 'listen', '~> 3.0'
|
18
|
+
spec.add_dependency 'diplomat', '~> 0.15'
|
19
|
+
spec.add_dependency 'trollop', '~> 2.0'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
|
+
end
|
data/fixtures/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
daemons (1.1.9)
|
5
|
+
rack (1.6.0)
|
6
|
+
rack-protection (1.5.1)
|
7
|
+
rack
|
8
|
+
sinatra (1.3.6)
|
9
|
+
rack (~> 1.4)
|
10
|
+
rack-protection (~> 1.3)
|
11
|
+
tilt (~> 1.3, >= 1.3.3)
|
12
|
+
tilt (1.4.1)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
rack (~> 1.0)
|
19
|
+
sinatra (~> 1.3)
|
data/fixtures/config.ru
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'sinatra'
|
4
|
+
|
5
|
+
Signal.trap('HUP') do
|
6
|
+
puts 'I got a SIGHUP'
|
7
|
+
end
|
8
|
+
|
9
|
+
Signal.trap('USR2') do
|
10
|
+
puts 'I got a SIGUSR2'
|
11
|
+
end
|
12
|
+
|
13
|
+
app_dir = File.expand_path('../app', __FILE__)
|
14
|
+
|
15
|
+
Dir.glob(File.join(app_dir, '**', '*')).each do |f|
|
16
|
+
require f
|
17
|
+
end
|
18
|
+
|
19
|
+
set :environment, :development
|
20
|
+
set :run, false
|
21
|
+
set :raise_errors, true
|
22
|
+
|
23
|
+
if ENV['DIE_DIE_DIE']
|
24
|
+
puts "I am dying as requested by ENV['DIE_DIE_DIE']"
|
25
|
+
exit(42)
|
26
|
+
else
|
27
|
+
puts "I am up and running"
|
28
|
+
run Sinatra::Application
|
29
|
+
end
|
data/lib/cmdb.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cmdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- RightScale
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: listen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: diplomat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.15'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: trollop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
description: Reads CMDB variables from files, Consul, and elsewhere.
|
70
|
+
email:
|
71
|
+
- rubygems@rightscale.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- TODO.md
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- cmdb.gemspec
|
88
|
+
- fixtures/Gemfile
|
89
|
+
- fixtures/Gemfile.lock
|
90
|
+
- fixtures/app/widgets.rb
|
91
|
+
- fixtures/config.ru
|
92
|
+
- lib/cmdb.rb
|
93
|
+
homepage: https://github.com/rightscale/cmdb
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '2.0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.5
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Command-line tool for configuration manegement databases
|
117
|
+
test_files: []
|
118
|
+
has_rdoc:
|