joyent-provisioner 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/joyent-provisioner.gemspec +2 -2
- data/lib/joyent-provisioner.rb +1 -3
- data/lib/provisioner/cli/bootstrap.rb +1 -1
- data/lib/provisioner/cli/provision.rb +1 -1
- data/lib/provisioner/command/base.rb +3 -2
- data/lib/provisioner/command/provision.rb +13 -3
- data/lib/provisioner/host_ip.rb +3 -3
- data/lib/provisioner/version.rb +1 -1
- data/spec/provisioner/command/provision_spec.rb +18 -5
- data/spec/provisioner/host_ip_spec.rb +9 -5
- data/spec/spec_helper.rb +14 -0
- data/spec/support/aruba.rb +5 -0
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa248d1cf9f18ede6e0ad3e8485fe325ba1fc95f
|
4
|
+
data.tar.gz: 40f04cc5329317d54febf9ff74317c5dbd26b5ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a444c2695fdfd38d8af205800c07f49329f10e8daeceef49ca0d127cf8051a41ed2802981fe4615224cf255cafb06a5c0559ea6119d7c54bb4370e04d422be97
|
7
|
+
data.tar.gz: 70f817b1523020ed4650f698be20513a65b61371a11549e9b789b7d6773f05aa339b74f5458b3e15640011cca6919fa601e74e41be7a7fc1c374bd77ac7effa2
|
data/joyent-provisioner.gemspec
CHANGED
@@ -20,8 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'mixlib-cli'
|
22
22
|
spec.add_dependency 'chef'
|
23
|
-
spec.add_dependency 'knife-joyent'
|
24
|
-
spec.add_dependency 'colorize'
|
23
|
+
spec.add_dependency 'knife-joyent', '>= 0.3.4'
|
25
24
|
|
26
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
27
26
|
spec.add_development_dependency 'rake'
|
@@ -29,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
29
28
|
spec.add_development_dependency 'guard-rspec'
|
30
29
|
spec.add_development_dependency 'rspec'
|
31
30
|
spec.add_development_dependency 'pry-debugger'
|
31
|
+
spec.add_development_dependency 'aruba-doubles'
|
32
32
|
end
|
data/lib/joyent-provisioner.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
module Provisioner
|
2
2
|
end
|
3
3
|
|
4
|
-
require 'colorize'
|
5
|
-
|
6
4
|
require_relative 'provisioner/usage'
|
7
5
|
require_relative 'provisioner/logger'
|
8
6
|
require_relative 'provisioner/helper'
|
9
7
|
require_relative 'provisioner/configuration'
|
10
8
|
require_relative 'provisioner/host_ip'
|
11
9
|
require_relative 'provisioner/cli'
|
12
|
-
require_relative 'provisioner/command/base'
|
10
|
+
require_relative 'provisioner/command/base'
|
@@ -3,7 +3,8 @@ module Provisioner
|
|
3
3
|
class Base
|
4
4
|
attr_accessor :image, :flavor, :distro, :networks, :run_list,
|
5
5
|
:host_sequence, :host_prefix, :environment, :host_suffix,
|
6
|
-
:host_presuffix, :log_dir, :host_number, :options, :ssh_user
|
6
|
+
:host_presuffix, :log_dir, :host_number, :options, :ssh_user,
|
7
|
+
:tags
|
7
8
|
|
8
9
|
def initialize(template_configuration, options = {})
|
9
10
|
@options = options
|
@@ -51,7 +52,7 @@ module Provisioner
|
|
51
52
|
|
52
53
|
def shellout(command)
|
53
54
|
puts "Running provision command:"
|
54
|
-
puts command
|
55
|
+
puts command
|
55
56
|
system(command)
|
56
57
|
end
|
57
58
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Provisioner
|
2
4
|
module Command
|
3
5
|
class Provision < Base
|
@@ -14,11 +16,19 @@ module Provisioner
|
|
14
16
|
"--networks #{networks}",
|
15
17
|
"--environment #{environment}",
|
16
18
|
"--node-name #{host_name}",
|
17
|
-
]
|
19
|
+
]
|
20
|
+
|
18
21
|
|
19
22
|
log_path = "#{log_dir}/#{host_name}_provision.log"
|
20
|
-
command << "
|
21
|
-
command << "
|
23
|
+
command << "--run-list #{run_list}" if run_list
|
24
|
+
command << "--tags '#{encoded_tags}'" if tags
|
25
|
+
command << "2>&1 > #{log_path} &"
|
26
|
+
|
27
|
+
command.join(' ')
|
28
|
+
end
|
29
|
+
|
30
|
+
def encoded_tags
|
31
|
+
JSON.dump(tags)
|
22
32
|
end
|
23
33
|
|
24
34
|
end
|
data/lib/provisioner/host_ip.rb
CHANGED
@@ -12,14 +12,14 @@ module Provisioner
|
|
12
12
|
def self.ips
|
13
13
|
@ips = {}
|
14
14
|
server_list.each do |server|
|
15
|
-
hostname, ip = server.split(' ')
|
15
|
+
hostname, ip = server.split(' ').compact
|
16
16
|
@ips[hostname] = ip
|
17
17
|
end
|
18
18
|
@ips
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.server_list
|
22
|
-
@server_list ||= `knife joyent server list | awk '{print $2 " " $
|
22
|
+
@server_list ||= `knife joyent server list | awk '{print $2 " " $7}' | tail +2`.split("\n")
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
data/lib/provisioner/version.rb
CHANGED
@@ -4,12 +4,10 @@ describe Provisioner::Command::Provision do
|
|
4
4
|
let(:configuration) { Provisioner::Configuration.from_path('spec/fixtures/test.yml') }
|
5
5
|
|
6
6
|
describe '#shell_commands' do
|
7
|
-
|
8
7
|
context 'host is specified' do
|
9
|
-
|
10
8
|
let(:subject) { Provisioner::Command::Provision.new(template_configuration, number: '1') }
|
11
|
-
|
12
|
-
|
9
|
+
|
10
|
+
let(:command_options) { [
|
13
11
|
'--image 9ec5c0c-a941-11e2-a7dc-57a6b041988f',
|
14
12
|
'--flavor g3-highmemory-17.125-smartos',
|
15
13
|
'--distro smartos-base64',
|
@@ -17,8 +15,13 @@ describe Provisioner::Command::Provision do
|
|
17
15
|
'--environment test',
|
18
16
|
'--node-name memcached-sessions001.test',
|
19
17
|
'--run-list role[joyent]',
|
18
|
+
] }
|
19
|
+
|
20
|
+
let(:expected_command) { [
|
21
|
+
'knife joyent server create',
|
22
|
+
command_options,
|
20
23
|
'2>&1 > ./tmp/memcached-sessions001.test_provision.log &'
|
21
|
-
].join(' ')
|
24
|
+
].flatten.join(' ')}
|
22
25
|
|
23
26
|
context 'passing options directly' do
|
24
27
|
let(:template_configuration) { {
|
@@ -33,9 +36,19 @@ describe Provisioner::Command::Provision do
|
|
33
36
|
log_dir: './tmp',
|
34
37
|
run_list: 'role[joyent]'
|
35
38
|
} }
|
39
|
+
|
36
40
|
it 'returns expected command string' do
|
37
41
|
expect(subject.shell_commands).to eq([expected_command])
|
38
42
|
end
|
43
|
+
|
44
|
+
context 'tags are included' do
|
45
|
+
it 'passes tags to knife-joyent' do
|
46
|
+
template_configuration[:tags] = {a: 1, b: 2, c: 3}
|
47
|
+
command_options << "--tags '{\"a\":1,\"b\":2,\"c\":3}'"
|
48
|
+
|
49
|
+
expect(subject.shell_commands).to eq([expected_command])
|
50
|
+
end
|
51
|
+
end
|
39
52
|
end
|
40
53
|
|
41
54
|
context 'using the template from yaml configuration' do
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Provisioner::HostIP do
|
4
|
+
describe '.ip_for' do
|
5
|
+
let(:header) { "ID Name State Type Image Flavor IPs RAM Disk Tags\n" }
|
6
|
+
let(:server001) { "a67c6340-4bf4-11e3-8f96-0800200c9a66 app001.stage running smartmachine sdc:sdc:base64:13.1.0 g3-highmemory-17.125-smartos 1.1.1.1 17.12 GB 420 GB\n" }
|
7
|
+
let(:server002) { "eb332d70-4bf4-11e3-8f96-0800200c9a66 app002.stage running smartmachine sdc:sdc:base64:13.1.0 g3-highmemory-17.125-smartos 1.1.1.2 17.12 GB 420 GB\n" }
|
8
|
+
let(:servers) { [header, server001, server002].join }
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
before do
|
11
|
+
double_cmd('knife joyent server list', puts: servers)
|
12
|
+
end
|
9
13
|
|
10
|
-
describe '.ip_for' do
|
11
14
|
it 'returns the IP address given a hostname' do
|
12
15
|
expect(Provisioner::HostIP.ip_for('app001.stage')).to eq('1.1.1.1')
|
16
|
+
expect(Provisioner::HostIP.ip_for('app002.stage')).to eq('1.1.1.2')
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,9 @@
|
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
|
8
8
|
require 'joyent-provisioner'
|
9
|
+
require 'aruba-doubles'
|
10
|
+
|
11
|
+
require 'support/aruba'
|
9
12
|
|
10
13
|
RSpec.configure do |config|
|
11
14
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
@@ -17,4 +20,15 @@ RSpec.configure do |config|
|
|
17
20
|
# the seed, which is printed after each run.
|
18
21
|
# --seed 1234
|
19
22
|
config.order = 'random'
|
23
|
+
|
24
|
+
config.include ArubaDoubles
|
25
|
+
|
26
|
+
config.before(:each) do
|
27
|
+
ArubaDoubles::Double.setup
|
28
|
+
end
|
29
|
+
|
30
|
+
config.after(:each) do
|
31
|
+
ArubaDoubles::Double.teardown
|
32
|
+
history.clear
|
33
|
+
end
|
20
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joyent-provisioner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Gredeskoul
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mixlib-cli
|
@@ -46,28 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - '>='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
type: :runtime
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - '>='
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: colorize
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
49
|
+
version: 0.3.4
|
64
50
|
type: :runtime
|
65
51
|
prerelease: false
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
67
53
|
requirements:
|
68
54
|
- - '>='
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
56
|
+
version: 0.3.4
|
71
57
|
- !ruby/object:Gem::Dependency
|
72
58
|
name: bundler
|
73
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,6 +138,20 @@ dependencies:
|
|
152
138
|
- - '>='
|
153
139
|
- !ruby/object:Gem::Version
|
154
140
|
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: aruba-doubles
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
155
|
description: Wrapper gem around provisioning clusters of servers on Joyent cloud
|
156
156
|
email:
|
157
157
|
- kigster@gmail.com
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- spec/provisioner/configuration_spec.rb
|
196
196
|
- spec/provisioner/host_ip_spec.rb
|
197
197
|
- spec/spec_helper.rb
|
198
|
+
- spec/support/aruba.rb
|
198
199
|
homepage: ''
|
199
200
|
licenses:
|
200
201
|
- MIT
|
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
216
|
version: '0'
|
216
217
|
requirements: []
|
217
218
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.0.
|
219
|
+
rubygems_version: 2.0.3
|
219
220
|
signing_key:
|
220
221
|
specification_version: 4
|
221
222
|
summary: Wrapper gem around provisioning clusters of servers on Joyent cloud
|
@@ -228,3 +229,4 @@ test_files:
|
|
228
229
|
- spec/provisioner/configuration_spec.rb
|
229
230
|
- spec/provisioner/host_ip_spec.rb
|
230
231
|
- spec/spec_helper.rb
|
232
|
+
- spec/support/aruba.rb
|