erforscher 1.0.0.pre0 → 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -8
- data/lib/erforscher/cli.rb +1 -0
- data/lib/erforscher/hostsfile.rb +8 -4
- data/lib/erforscher/runner.rb +3 -3
- data/lib/erforscher/version.rb +1 -1
- data/spec/erforscher/hostsfile_spec.rb +10 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec74a3e7f15636cc457795d15f7f4bb4407d849a
|
4
|
+
data.tar.gz: e91330cd59d4dd4d8e52055f65590074b207227a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8558702da92aebe8b5cfce3182695662e630cbc6c7d02d62d5e19365c4240b2f08d1e47037d947f465f3461ceac040e9658c5126e62ee075339095dbbd608ee
|
7
|
+
data.tar.gz: a6689f5c8736b24ef99e4756df726c0ecc57292043a58e338dae40a2dbe213dec7e0e84c645d42fcaa53fdbf3db0c32ccab804dc5cbcbecf585036b10800ccea
|
data/README.md
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# Erforscher
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
to
|
3
|
+
[![Build Status](https://travis-ci.org/mthssdrbrg/erforscher.svg?branch=master)](https://travis-ci.org/mthssdrbrg/erforscher)
|
4
|
+
|
5
|
+
Erforscher, German for "explorer", is a poor man's service discovery tool that
|
6
|
+
utilizes the AWS EC2 APIs to filter instances from a configured set of `tags`
|
7
|
+
and writes hostnames (derived from a configured `name` tag) and private IP address
|
8
|
+
mappings to `/etc/hosts` (or any file of your choosing).
|
7
9
|
|
8
10
|
By default, Erforscher will look for a configuration file in the following
|
9
11
|
places (and in the given order);
|
10
12
|
|
11
|
-
*
|
12
|
-
*
|
13
|
+
* `$HOME/.erforscher.yml`
|
14
|
+
* `/etc/erforscher.yml`
|
13
15
|
|
14
16
|
As indicated below it's also possible to give the path to a configuration file
|
15
17
|
using the `-c|--config` option, and in that case the given path will be used.
|
@@ -19,8 +21,12 @@ to merge settings if there should be files in the above mentioned places.
|
|
19
21
|
|
20
22
|
## Installation
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
```
|
25
|
+
gem install erforscher --pre
|
26
|
+
```
|
27
|
+
|
28
|
+
It will be available as `omnibus` packages and most likely a `Chef` cookbook in
|
29
|
+
the near future.
|
24
30
|
|
25
31
|
## Usage
|
26
32
|
|
@@ -42,3 +48,19 @@ tags:
|
|
42
48
|
- environment: 'production'
|
43
49
|
service: 'database'
|
44
50
|
```
|
51
|
+
|
52
|
+
## Copyright
|
53
|
+
|
54
|
+
Copyright :: 2014 Mathias Söderberg
|
55
|
+
|
56
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
57
|
+
you may not use this file except in compliance with the License.
|
58
|
+
You may obtain a copy of the License at
|
59
|
+
|
60
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
61
|
+
|
62
|
+
Unless required by applicable law or agreed to in writing, software
|
63
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
64
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
65
|
+
See the License for the specific language governing permissions and
|
66
|
+
limitations under the License.
|
data/lib/erforscher/cli.rb
CHANGED
data/lib/erforscher/hostsfile.rb
CHANGED
@@ -16,26 +16,30 @@ module Erforscher
|
|
16
16
|
write_footer
|
17
17
|
discard_old_entries
|
18
18
|
copy_after_footer
|
19
|
+
nil
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
+
def switch
|
22
23
|
@new_file.close
|
24
|
+
@current_file.close
|
23
25
|
@fileutils.mv(current_path, current_prev_path)
|
24
26
|
@fileutils.mv(new_path, current_path)
|
27
|
+
@fileutils.chmod(0644, current_path)
|
28
|
+
nil
|
25
29
|
end
|
26
30
|
|
27
31
|
private
|
28
32
|
|
29
33
|
def new_path
|
30
|
-
@new_file.path
|
34
|
+
@new_path ||= @new_file.path
|
31
35
|
end
|
32
36
|
|
33
37
|
def current_path
|
34
|
-
absolute_path(@current_file)
|
38
|
+
@current_path ||= absolute_path(@current_file)
|
35
39
|
end
|
36
40
|
|
37
41
|
def current_prev_path
|
38
|
-
%(#{absolute_path(@current_file)}.prev)
|
42
|
+
@current_prev_path ||= %(#{absolute_path(@current_file)}.prev)
|
39
43
|
end
|
40
44
|
|
41
45
|
def absolute_path(f)
|
data/lib/erforscher/runner.rb
CHANGED
@@ -12,9 +12,9 @@ module Erforscher
|
|
12
12
|
|
13
13
|
def run
|
14
14
|
explored = explorer.discover(@config['tags'])
|
15
|
-
entries = explored.
|
16
|
-
hostsfile.write(entries)
|
17
|
-
hostsfile.
|
15
|
+
entries = explored.map { |ex| formatter.format(ex) }
|
16
|
+
hostsfile.write(entries.sort)
|
17
|
+
hostsfile.switch
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
data/lib/erforscher/version.rb
CHANGED
@@ -100,7 +100,7 @@ module Erforscher
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe '#
|
103
|
+
describe '#switch' do
|
104
104
|
let :new_file do
|
105
105
|
Tempfile.new('new_file')
|
106
106
|
end
|
@@ -118,13 +118,17 @@ module Erforscher
|
|
118
118
|
end
|
119
119
|
|
120
120
|
before do
|
121
|
-
hostsfile.
|
121
|
+
hostsfile.switch
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'closes the new file' do
|
125
125
|
new_file.should be_closed
|
126
126
|
end
|
127
127
|
|
128
|
+
it 'closes the old file' do
|
129
|
+
current_file.should be_closed
|
130
|
+
end
|
131
|
+
|
128
132
|
it 'backups the previous file' do
|
129
133
|
fileutils.should have_received(:mv).with(absolute_current_path, %(#{absolute_current_path}.prev))
|
130
134
|
end
|
@@ -132,6 +136,10 @@ module Erforscher
|
|
132
136
|
it 'renames the new file' do
|
133
137
|
fileutils.should have_received(:mv).with(absolute_new_path, absolute_current_path)
|
134
138
|
end
|
139
|
+
|
140
|
+
it 'applies 0644 permissions on the new file' do
|
141
|
+
fileutils.should have_received(:chmod).with(0644, absolute_current_path)
|
142
|
+
end
|
135
143
|
end
|
136
144
|
end
|
137
145
|
end
|