rouster 0.5 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.reek +63 -0
- data/.travis.yml +11 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +102 -0
- data/README.md +233 -7
- data/Rakefile +52 -34
- data/Vagrantfile +26 -8
- data/examples/aws.rb +85 -0
- data/examples/openstack.rb +61 -0
- data/examples/passthrough.rb +71 -0
- data/lib/rouster.rb +380 -262
- data/lib/rouster/deltas.rb +470 -138
- data/lib/rouster/puppet.rb +155 -26
- data/lib/rouster/testing.rb +205 -46
- data/lib/rouster/tests.rb +40 -11
- data/lib/rouster/vagrant.rb +311 -0
- data/path_helper.rb +3 -4
- data/plugins/aws.rb +347 -0
- data/plugins/openstack.rb +136 -0
- data/test/basic.rb +4 -1
- data/test/functional/deltas/test_get_crontab.rb +64 -2
- data/test/functional/deltas/test_get_groups.rb +74 -2
- data/test/functional/deltas/test_get_os.rb +68 -0
- data/test/functional/deltas/test_get_packages.rb +73 -6
- data/test/functional/deltas/test_get_ports.rb +26 -1
- data/test/functional/deltas/test_get_services.rb +43 -5
- data/test/functional/deltas/test_get_users.rb +35 -2
- data/test/functional/puppet/test_facter.rb +41 -1
- data/test/functional/test_caching.rb +2 -2
- data/test/functional/test_inspect.rb +1 -1
- data/test/functional/test_is_file.rb +17 -1
- data/test/functional/test_is_in_file.rb +40 -0
- data/test/functional/test_new.rb +233 -22
- data/test/functional/test_passthroughs.rb +94 -0
- data/test/functional/test_put.rb +2 -2
- data/test/functional/test_validate_file.rb +104 -3
- data/test/puppet/test_apply.rb +8 -6
- data/test/unit/puppet/resources/puppet_run_with_failed_exec +59 -0
- data/test/unit/puppet/resources/puppet_run_with_successful_exec +61 -0
- data/test/unit/puppet/test_get_puppet_star.rb +27 -4
- data/test/unit/puppet/test_puppet_parsing.rb +44 -0
- data/test/unit/test_new.rb +88 -0
- data/test/unit/test_parse_ls_string.rb +67 -0
- data/test/unit/testing/resources/osx-launchd +285 -0
- data/test/unit/testing/resources/rhel-systemd +46 -0
- data/test/unit/testing/resources/rhel-systemv +41 -0
- data/test/unit/testing/resources/rhel-upstart +20 -0
- data/test/unit/testing/test_get_services.rb +178 -0
- data/test/unit/testing/test_validate_cron.rb +78 -0
- data/test/unit/testing/test_validate_package.rb +36 -10
- data/test/unit/testing/test_validate_port.rb +5 -0
- metadata +42 -21
- data/test/puppet/test_roles.rb +0 -186
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6badce99c05cdd7080ee400746d3c2b73a550cf
|
4
|
+
data.tar.gz: b776da73cf962263b7a9d2c0ee9fedef736d926d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0b36efffe024aa6f50bc2e4ca27aaa8be09224019b4fcd7a15e02a1be28b91b33e0050043879d34e63121a61832176d0fe81acfa0f849f80e0a67c4f03ef37
|
7
|
+
data.tar.gz: dfe3b1e7d14c1a9aae10a86eaa26f876c411999152deeb4d220dc4dc685c5706f915f8fb9dfeb4790b73d800e1f8823468d5f5f567de7d5df2208ea55ff96bd7
|
data/.gitignore
CHANGED
data/.reek
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
Attribute:
|
4
|
+
enabled: false
|
5
|
+
|
6
|
+
# so judgy.. and without context
|
7
|
+
BooleanParameter:
|
8
|
+
enabled: false
|
9
|
+
|
10
|
+
ControlParameter:
|
11
|
+
enabled: false
|
12
|
+
|
13
|
+
DataClump:
|
14
|
+
min_clump_size: 4
|
15
|
+
|
16
|
+
DuplicateMethodCall:
|
17
|
+
enabled: false
|
18
|
+
|
19
|
+
# this is not a real thing
|
20
|
+
FeatureEnvy:
|
21
|
+
enabled: false
|
22
|
+
|
23
|
+
# this should have understanding of non-required parameters
|
24
|
+
LongParameterList:
|
25
|
+
max_params: 5
|
26
|
+
|
27
|
+
NestedIterators:
|
28
|
+
max_allowed_nesting: 3
|
29
|
+
|
30
|
+
# you don't know my life
|
31
|
+
NilCheck:
|
32
|
+
enabled: false
|
33
|
+
|
34
|
+
# more lacking context judgement - when _would_ you be ok with '!' ?
|
35
|
+
PrimaDonnaMethod:
|
36
|
+
enabled: false
|
37
|
+
|
38
|
+
# this feels a bit arbitrary.. maybe would make more sense if was an average
|
39
|
+
TooManyStatements:
|
40
|
+
max_statements: 30
|
41
|
+
|
42
|
+
# see above
|
43
|
+
TooManyInstanceVariables:
|
44
|
+
max_instance_variables: 20
|
45
|
+
|
46
|
+
# see above
|
47
|
+
TooManyMethods:
|
48
|
+
max_methods: 20
|
49
|
+
|
50
|
+
# i don't name my exceptions specifically. that doesn't make me a bad person.
|
51
|
+
UncommunicativeVariableName:
|
52
|
+
accept: /^[a|b|e|f|g|h|i|j|k|l|m|p|r|s|u|v]$/
|
53
|
+
|
54
|
+
# or my comparators in ~sort() functions
|
55
|
+
## https://github.com/troessner/reek/issues/886
|
56
|
+
UncommunicativeParameterName:
|
57
|
+
accept:
|
58
|
+
- a
|
59
|
+
- b
|
60
|
+
|
61
|
+
# got dinged for using class variables.. how else would you use self.startup?
|
62
|
+
exclude_paths:
|
63
|
+
- test/
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
ruby '2.0.0'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'json'
|
6
|
+
gem 'log4r', '~> 1.1.9'
|
7
|
+
gem 'net-scp'
|
8
|
+
gem 'net-ssh'
|
9
|
+
gem 'rake', '= 10.4.2'
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem 'test-unit', '~> 3.0.0'
|
13
|
+
gem 'reek', '= 3.10.2'
|
14
|
+
end
|
15
|
+
|
16
|
+
gem 'fog', '= 1.24.0', :groups => [:aws, :openstack]
|
17
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.3.0)
|
5
|
+
axiom-types (0.1.1)
|
6
|
+
descendants_tracker (~> 0.0.4)
|
7
|
+
ice_nine (~> 0.11.0)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
9
|
+
builder (3.2.2)
|
10
|
+
codeclimate-engine-rb (0.3.1)
|
11
|
+
virtus (~> 1.0)
|
12
|
+
coercible (1.0.0)
|
13
|
+
descendants_tracker (~> 0.0.1)
|
14
|
+
descendants_tracker (0.0.4)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
16
|
+
equalizer (0.0.11)
|
17
|
+
excon (0.40.0)
|
18
|
+
fog (1.24.0)
|
19
|
+
fog-brightbox
|
20
|
+
fog-core (~> 1.23)
|
21
|
+
fog-json
|
22
|
+
fog-radosgw (>= 0.0.2)
|
23
|
+
fog-sakuracloud (>= 0.0.4)
|
24
|
+
fog-softlayer
|
25
|
+
ipaddress (~> 0.5)
|
26
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
27
|
+
fog-brightbox (0.5.1)
|
28
|
+
fog-core (~> 1.22)
|
29
|
+
fog-json
|
30
|
+
inflecto
|
31
|
+
fog-core (1.24.0)
|
32
|
+
builder
|
33
|
+
excon (~> 0.38)
|
34
|
+
formatador (~> 0.2)
|
35
|
+
mime-types
|
36
|
+
net-scp (~> 1.1)
|
37
|
+
net-ssh (>= 2.1.3)
|
38
|
+
fog-json (1.0.0)
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
fog-radosgw (0.0.3)
|
41
|
+
fog-core (>= 1.21.0)
|
42
|
+
fog-json
|
43
|
+
fog-xml (>= 0.0.1)
|
44
|
+
fog-sakuracloud (0.1.1)
|
45
|
+
fog-core
|
46
|
+
fog-json
|
47
|
+
fog-softlayer (0.3.20)
|
48
|
+
fog-core
|
49
|
+
fog-json
|
50
|
+
fog-xml (0.1.0)
|
51
|
+
fog-core
|
52
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
53
|
+
formatador (0.2.5)
|
54
|
+
ice_nine (0.11.2)
|
55
|
+
inflecto (0.0.2)
|
56
|
+
ipaddress (0.8.0)
|
57
|
+
json (1.8.1)
|
58
|
+
log4r (1.1.10)
|
59
|
+
mime-types (2.4.1)
|
60
|
+
mini_portile (0.6.0)
|
61
|
+
multi_json (1.10.1)
|
62
|
+
net-scp (1.2.1)
|
63
|
+
net-ssh (>= 2.6.5)
|
64
|
+
net-ssh (2.9.1)
|
65
|
+
nokogiri (1.6.3.1)
|
66
|
+
mini_portile (= 0.6.0)
|
67
|
+
parser (2.3.3.0)
|
68
|
+
ast (~> 2.2)
|
69
|
+
power_assert (0.1.4)
|
70
|
+
rainbow (2.1.0)
|
71
|
+
rake (10.4.2)
|
72
|
+
reek (3.10.2)
|
73
|
+
codeclimate-engine-rb (~> 0.3.1)
|
74
|
+
parser (~> 2.3, >= 2.3.0.6)
|
75
|
+
rainbow (~> 2.0)
|
76
|
+
test-unit (3.0.2)
|
77
|
+
power_assert
|
78
|
+
thread_safe (0.3.5)
|
79
|
+
virtus (1.0.5)
|
80
|
+
axiom-types (~> 0.1)
|
81
|
+
coercible (~> 1.0)
|
82
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
83
|
+
equalizer (~> 0.0, >= 0.0.9)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
ruby
|
87
|
+
|
88
|
+
DEPENDENCIES
|
89
|
+
fog (= 1.24.0)
|
90
|
+
json
|
91
|
+
log4r (~> 1.1.9)
|
92
|
+
net-scp
|
93
|
+
net-ssh
|
94
|
+
rake (= 10.4.2)
|
95
|
+
reek (= 3.10.2)
|
96
|
+
test-unit (~> 3.0.0)
|
97
|
+
|
98
|
+
RUBY VERSION
|
99
|
+
ruby 2.0.0p648
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
1.13.6
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Rouster
|
2
2
|
======
|
3
3
|
|
4
|
+
[![build status](https://travis-ci.org/chorankates/rouster.svg)](https://travis-ci.org/chorankates/rouster) [![Gem Version](https://badge.fury.io/rb/rouster.svg)](https://rubygems.org/gems/rouster)
|
5
|
+
|
4
6
|
```rb
|
5
7
|
Rouster.is_a?('abstraction layer for controlling Vagrant virtual machines')
|
6
8
|
=> true
|
@@ -24,12 +26,29 @@ The first implementation of Rouster was in Perl, called [Salesforce::Vagrant](ht
|
|
24
26
|
|
25
27
|
* [Ruby](http://rubylang.org), version 2.0+ (best attempt made to support 1.8.7 and 1.9.3 as well)
|
26
28
|
* [Vagrant](http://vagrantup.com), version 1.0.5+
|
27
|
-
|
28
|
-
|
29
|
+
* Gems
|
30
|
+
* json
|
31
|
+
* log4r
|
32
|
+
* net-scp
|
33
|
+
* net-ssh
|
34
|
+
* fog (only if using AWS or OpenStack)
|
29
35
|
|
30
36
|
Note: Rouster should work exactly the same on Windows as it does on \*nix and OSX (minus rouster/deltas.rb functionality, at least currently),
|
31
37
|
but no real testing has been done to confirm this. Please file issues as appropriate.
|
32
38
|
|
39
|
+
### From-source local usage (latest)
|
40
|
+
|
41
|
+
```sh
|
42
|
+
git clone https://github.com/chorankates/rouster.git
|
43
|
+
cd rouster
|
44
|
+
bundle install # use :aws to pull in fog
|
45
|
+
...
|
46
|
+
irb(main):001:0> require './path_helper.rb'
|
47
|
+
=> true
|
48
|
+
irb(main):002:0> require 'rouster'
|
49
|
+
=> true
|
50
|
+
```
|
51
|
+
|
33
52
|
### From-source installation (latest)
|
34
53
|
|
35
54
|
```sh
|
@@ -37,13 +56,13 @@ git clone https://github.com/chorankates/rouster.git
|
|
37
56
|
cd rouster
|
38
57
|
rake buildgem
|
39
58
|
gem install rouster-<version>.gem
|
59
|
+
...
|
60
|
+
irb(main):001:0> require 'rouster'
|
61
|
+
=> true
|
40
62
|
```
|
41
63
|
|
42
64
|
### pre-built gem installation (stable)
|
43
65
|
|
44
|
-
[RubyGems](http://rubygems.org/gems/rouster)
|
45
|
-
[![Gem Version](https://badge.fury.io/rb/rouster.png)](http://badge.fury.io/rb/rouster)
|
46
|
-
|
47
66
|
```sh
|
48
67
|
gem install rouster
|
49
68
|
```
|
@@ -127,6 +146,89 @@ app.get('/tmp/foo')
|
|
127
146
|
app.destroy()
|
128
147
|
```
|
129
148
|
|
149
|
+
### advanced instantiation (passthroughs!)
|
150
|
+
|
151
|
+
detailed options in ```examples/passthrough.rb```, ```examples/aws.rb``` and ```examples/openstack.rb```
|
152
|
+
|
153
|
+
since Rouster only requires an SSH connection to control a machine, why stop at Vagrant?
|
154
|
+
|
155
|
+
```rb
|
156
|
+
require 'rouster'
|
157
|
+
require 'rouster/plugins/aws'
|
158
|
+
require 'rouster/plugins/openstack'
|
159
|
+
|
160
|
+
# control the machine rouster itself is running on
|
161
|
+
local = Rouster.new(:name => 'local', :passthrough => { :type => :local } }
|
162
|
+
|
163
|
+
# control a remote machine
|
164
|
+
remote = Rouster.new(
|
165
|
+
:name => 'remote',
|
166
|
+
:passthrough => {
|
167
|
+
:type => :remote,
|
168
|
+
:host => 'foo.bar.com',
|
169
|
+
:user => 'keanu',
|
170
|
+
:key => '/path/to/private/key',
|
171
|
+
}
|
172
|
+
|
173
|
+
:sudo => true, # false by default, enabling requires that sshd is not enforcing 'requiretty'
|
174
|
+
)
|
175
|
+
|
176
|
+
# control a running EC2 instance
|
177
|
+
aws_already_running = Rouster.new(
|
178
|
+
:name => 'cloudy',
|
179
|
+
:passthrough => {
|
180
|
+
:type => :aws,
|
181
|
+
:instance => 'your-instance-id',
|
182
|
+
:keypair => 'your-keypair-name',
|
183
|
+
}
|
184
|
+
)
|
185
|
+
|
186
|
+
# start and control an EC2 instance
|
187
|
+
aws_start_me_up = Rouster.new(
|
188
|
+
:name => 'bgates',
|
189
|
+
:passthrough => {
|
190
|
+
:type => :aws,
|
191
|
+
:ami => 'your-ami-id',
|
192
|
+
:security_groups => 'your-security-groups',
|
193
|
+
:key_id => 'your-aws-key-id', # defaults to ${AWS_ACCESS_KEY_ID}
|
194
|
+
:secret_key => 'your-aws-secret-key', # defaults to ${AWS_SECRET_ACCESS_KEY}
|
195
|
+
}
|
196
|
+
)
|
197
|
+
|
198
|
+
# create a remote OpenStack instance
|
199
|
+
ostack = Rouster.new(
|
200
|
+
:name => 'ostack-testing',
|
201
|
+
:passthrough => {
|
202
|
+
:type => :openstack,
|
203
|
+
:openstack_auth_url => 'http://hostname.domain.com:5000/v2.0/tokens',
|
204
|
+
:openstack_username => 'some_console_user',
|
205
|
+
:openstack_tenant => 'tenant_id',
|
206
|
+
:user => 'some_ssh_userid',
|
207
|
+
:keypair => 'keypair_name',
|
208
|
+
:image_ref => 'c0340afb-577d-4db6-1234-aebdd6d1838f',
|
209
|
+
:flavor_ref => '547d9af5-096c-44a3-1234-7d23162556b8',
|
210
|
+
:openstack_api_key => 'some_api_key',
|
211
|
+
:key => '/path/to/private/key.pem',
|
212
|
+
},
|
213
|
+
:sudo => true, # false by default, enabling requires that sshd is not enforcing 'requiretty'
|
214
|
+
)
|
215
|
+
|
216
|
+
# control a running OpenStack instance
|
217
|
+
openstack_already_running = Rouster.new(
|
218
|
+
:name => 'ostack-copy',
|
219
|
+
:passthrough => {
|
220
|
+
:type => :openstack,
|
221
|
+
:openstack_auth_url => 'http://hostname.domain.com:5000/v2.0/tokens',
|
222
|
+
:openstack_username => 'some_console_user',
|
223
|
+
:openstack_tenant => 'tenant_id',
|
224
|
+
:user => 'ssh_user',
|
225
|
+
:keypair => 'keypair_name',
|
226
|
+
:instance => 'your-instance-id',
|
227
|
+
},
|
228
|
+
)
|
229
|
+
|
230
|
+
```
|
231
|
+
|
130
232
|
### functional puppet test
|
131
233
|
|
132
234
|
```rb
|
@@ -170,6 +272,130 @@ end
|
|
170
272
|
## Base Methods
|
171
273
|
|
172
274
|
```rb
|
173
|
-
irb(main):
|
174
|
-
=>
|
275
|
+
irb(main):001:0> require './path_helper.rb'
|
276
|
+
=> true
|
277
|
+
irb(main):002:0> require 'rouster'
|
278
|
+
=> true
|
279
|
+
irb(main):003:0> pp (Rouster.new(:name => 'app').methods - Object.methods).sort
|
280
|
+
=> [
|
281
|
+
[:_run,
|
282
|
+
:cache,
|
283
|
+
:cache_timeout,
|
284
|
+
:check_key_permissions,
|
285
|
+
:connect_ssh_tunnel,
|
286
|
+
:deltas,
|
287
|
+
:destroy,
|
288
|
+
:dir,
|
289
|
+
:dirs,
|
290
|
+
:disconnect_ssh_tunnel,
|
291
|
+
:exitcode,
|
292
|
+
:facts,
|
293
|
+
:facts=,
|
294
|
+
:file,
|
295
|
+
:files,
|
296
|
+
:generate_unique_mac,
|
297
|
+
:get,
|
298
|
+
:get_crontab,
|
299
|
+
:get_groups,
|
300
|
+
:get_output,
|
301
|
+
:get_packages,
|
302
|
+
:get_ports,
|
303
|
+
:get_services,
|
304
|
+
:get_ssh_info,
|
305
|
+
:get_users,
|
306
|
+
:halt,
|
307
|
+
:is_available_via_ssh?,
|
308
|
+
:is_dir?,
|
309
|
+
:is_executable?,
|
310
|
+
:is_file?,
|
311
|
+
:is_group?,
|
312
|
+
:is_in_file?,
|
313
|
+
:is_in_path?,
|
314
|
+
:is_package?,
|
315
|
+
:is_passthrough?,
|
316
|
+
:is_port_active?,
|
317
|
+
:is_port_open?,
|
318
|
+
:is_process_running?,
|
319
|
+
:is_readable?,
|
320
|
+
:is_service?,
|
321
|
+
:is_service_running?,
|
322
|
+
:is_symlink?,
|
323
|
+
:is_user?,
|
324
|
+
:is_user_in_group?,
|
325
|
+
:is_vagrant_running?,
|
326
|
+
:is_writeable?,
|
327
|
+
:logger,
|
328
|
+
:os_type,
|
329
|
+
:output,
|
330
|
+
:package,
|
331
|
+
:parse_ls_string,
|
332
|
+
:passthrough,
|
333
|
+
:put,
|
334
|
+
:rebuild,
|
335
|
+
:restart,
|
336
|
+
:retries,
|
337
|
+
:run,
|
338
|
+
:sandbox_available?,
|
339
|
+
:sandbox_commit,
|
340
|
+
:sandbox_off,
|
341
|
+
:sandbox_on,
|
342
|
+
:sandbox_rollback,
|
343
|
+
:sshkey,
|
344
|
+
:status,
|
345
|
+
:suspend,
|
346
|
+
:traverse_up,
|
347
|
+
:unittest,
|
348
|
+
:up,
|
349
|
+
:uses_sudo?,
|
350
|
+
:vagrant,
|
351
|
+
:vagrantbinary,
|
352
|
+
:vagrantfile]
|
353
|
+
]
|
354
|
+
```
|
355
|
+
|
356
|
+
## AWS methods
|
357
|
+
```rb
|
358
|
+
irb(main):001:0> require './path_helper.rb'
|
359
|
+
=> true
|
360
|
+
irb(main):002:0> require 'rouster'
|
361
|
+
=> true
|
362
|
+
irb(main):003:0> require 'rouster/plugins/aws'
|
363
|
+
=> true
|
364
|
+
irb(main):004:0> pp (Rouster.new(:name => 'aws', :passthrough => { :type => :aws }).methods - Object.methods).sort
|
365
|
+
=> [
|
366
|
+
...
|
367
|
+
:aws_bootstrap,
|
368
|
+
:aws_connect,
|
369
|
+
:aws_connect_to_elb,
|
370
|
+
:aws_describe_instance,
|
371
|
+
:aws_destroy,
|
372
|
+
:aws_get_ami,
|
373
|
+
:aws_get_hostname,
|
374
|
+
:aws_get_instance,
|
375
|
+
:aws_get_ip,
|
376
|
+
:aws_get_metadata,
|
377
|
+
:aws_get_url,
|
378
|
+
:aws_get_userdata,
|
379
|
+
:aws_status,
|
380
|
+
:ec2,
|
381
|
+
:elb,
|
382
|
+
:elb_connect,
|
383
|
+
:find_ssh_elb,
|
384
|
+
:instance_data,
|
385
|
+
...
|
386
|
+
]
|
387
|
+
```
|
388
|
+
|
389
|
+
## Openstack methods
|
390
|
+
|
391
|
+
```rb
|
392
|
+
[
|
393
|
+
:ostack_connect,
|
394
|
+
:ostack_describe_instance,
|
395
|
+
:ostack_destroy,
|
396
|
+
:ostack_get_instance_id,
|
397
|
+
:ostack_get_ip,
|
398
|
+
:ostack_status,
|
399
|
+
:ostack_up
|
400
|
+
]
|
175
401
|
```
|