joyent-provisioner 0.2.0 → 0.3.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 +4 -4
- data/lib/provisioner/cli/bootstrap.rb +14 -1
- data/lib/provisioner/cli/provision.rb +1 -1
- data/lib/provisioner/command/base.rb +5 -4
- data/lib/provisioner/command/bootstrap.rb +12 -1
- data/lib/provisioner/version.rb +1 -1
- data/spec/provisioner/command/bootstrap_spec.rb +40 -4
- data/spec/provisioner/command/provision_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 112ca66cf4b1b153f6ec273ff04ba83ae59cd053
|
4
|
+
data.tar.gz: ea701940d4b0dddd2af5d402c2eac05952bfc88a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66e9595db1d605ef08471a86eb2632c71a3629f9ad352bb3e831731520870b2cca5733e570b90759b25837d52df81db51aaba068acaeb6d8f7088ecf039d8196
|
7
|
+
data.tar.gz: fc21b4800f1addad8e44cbc17b1dcbf70398a662594e597f68fb297e5f580fac34545a59413073a220b01c65f8a819ccbfd8e6d1b0c1449bad160356f3ddd9ac
|
@@ -5,6 +5,19 @@ class Provisioner::CLI::Bootstrap < Provisioner::CLI
|
|
5
5
|
|
6
6
|
banner 'Usage: provisioner bootstrap --config <path-to-config>.yml [options] '
|
7
7
|
|
8
|
+
option :reset,
|
9
|
+
short: '-R',
|
10
|
+
long: '--reset',
|
11
|
+
description: 'Path to the config file (YML)',
|
12
|
+
boolean: true,
|
13
|
+
required: false
|
14
|
+
|
15
|
+
option :sudo,
|
16
|
+
long: '--sudo',
|
17
|
+
description: 'Execute bootstrap via sudo',
|
18
|
+
boolean: false,
|
19
|
+
required: false
|
20
|
+
|
8
21
|
def run(argv = ARGV)
|
9
22
|
parse_options argv
|
10
23
|
enable_logger if config[:debug]
|
@@ -19,7 +32,7 @@ class Provisioner::CLI::Bootstrap < Provisioner::CLI
|
|
19
32
|
end
|
20
33
|
|
21
34
|
def provisioner_command
|
22
|
-
Provisioner::Command::Bootstrap.new(template_configuration.for_template(config[:template]), config
|
35
|
+
Provisioner::Command::Bootstrap.new(template_configuration.for_template(config[:template]), config)
|
23
36
|
end
|
24
37
|
|
25
38
|
end
|
@@ -19,7 +19,7 @@ class Provisioner::CLI::Provision < Provisioner::CLI
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def provisioner_command
|
22
|
-
Provisioner::Command::Provision.new(template_configuration.for_template(config[:template]), config
|
22
|
+
Provisioner::Command::Provision.new(template_configuration.for_template(config[:template]), config)
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -3,14 +3,15 @@ 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, :ssh_user
|
6
|
+
:host_presuffix, :log_dir, :host_number, :options, :ssh_user
|
7
7
|
|
8
|
-
def initialize(template_configuration,
|
9
|
-
@
|
8
|
+
def initialize(template_configuration, options = {})
|
9
|
+
@options = options
|
10
|
+
@host_number = options[:number]
|
10
11
|
template_configuration.each_pair do |key, value|
|
11
12
|
self.send("#{key}=", value)
|
12
13
|
end
|
13
|
-
@ssh_user = ssh_user if ssh_user
|
14
|
+
@ssh_user = options[:ssh_user] if options[:ssh_user]
|
14
15
|
raise "Log path is required" unless @log_dir
|
15
16
|
Dir.mkdir(log_dir) unless Dir.exists?(log_dir)
|
16
17
|
end
|
@@ -2,12 +2,22 @@ module Provisioner
|
|
2
2
|
module Command
|
3
3
|
class Bootstrap < Base
|
4
4
|
|
5
|
+
def use_sudo?
|
6
|
+
options[:sudo]
|
7
|
+
end
|
8
|
+
|
5
9
|
private
|
6
10
|
|
7
11
|
def shell_commands_for(number)
|
8
12
|
host = HostCommand.new(host_name(number), self)
|
9
13
|
|
10
|
-
[
|
14
|
+
commands = []
|
15
|
+
commands << host.reset_command if reset_chef?
|
16
|
+
commands << host.bootstrap_command
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset_chef?
|
20
|
+
options[:reset]
|
11
21
|
end
|
12
22
|
|
13
23
|
class HostCommand
|
@@ -36,6 +46,7 @@ module Provisioner
|
|
36
46
|
|
37
47
|
bootstrap_command << "--run-list #{context.run_list}" if context.run_list
|
38
48
|
bootstrap_command << "--ssh-user #{context.ssh_user}"
|
49
|
+
bootstrap_command << '--sudo' if context.use_sudo?
|
39
50
|
bootstrap_command << "2>&1 > #{context.log_dir}/#{name}_provision.log &"
|
40
51
|
bootstrap_command.join(' ')
|
41
52
|
end
|
data/lib/provisioner/version.rb
CHANGED
@@ -25,7 +25,7 @@ describe Provisioner::Command::Bootstrap do
|
|
25
25
|
|
26
26
|
context 'host is specified' do
|
27
27
|
|
28
|
-
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, '1') }
|
28
|
+
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, number: '1') }
|
29
29
|
|
30
30
|
let(:expected_bootstrap_command) { [
|
31
31
|
'knife bootstrap 1.2.3.4',
|
@@ -38,13 +38,30 @@ describe Provisioner::Command::Bootstrap do
|
|
38
38
|
].join(' ') }
|
39
39
|
|
40
40
|
it 'returns command string' do
|
41
|
-
expect(shell_commands[0]).to eq(
|
42
|
-
expect(shell_commands[1]).to eq(expected_bootstrap_command)
|
41
|
+
expect(shell_commands[0]).to eq(expected_bootstrap_command)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
45
|
context 'ssh user is overridden' do
|
47
|
-
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, '1', 'root') }
|
46
|
+
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, number: '1', ssh_user: 'root') }
|
47
|
+
|
48
|
+
let(:expected_bootstrap_command) { [
|
49
|
+
'knife bootstrap 1.2.3.4',
|
50
|
+
'--distro smartos-base64',
|
51
|
+
'--environment test',
|
52
|
+
'--node-name memcached-sessions001.c1.test',
|
53
|
+
'--run-list role[joyent]',
|
54
|
+
'--ssh-user root',
|
55
|
+
'2>&1 > ./tmp/memcached-sessions001.c1.test_provision.log &'
|
56
|
+
].join(' ') }
|
57
|
+
|
58
|
+
it 'returns command string' do
|
59
|
+
expect(shell_commands[0]).to eq(expected_bootstrap_command)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'reset is true' do
|
64
|
+
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, number: '1', ssh_user: 'root', reset: true) }
|
48
65
|
|
49
66
|
let(:expected_bootstrap_command) { [
|
50
67
|
'knife bootstrap 1.2.3.4',
|
@@ -61,6 +78,25 @@ describe Provisioner::Command::Bootstrap do
|
|
61
78
|
expect(shell_commands[1]).to eq(expected_bootstrap_command)
|
62
79
|
end
|
63
80
|
end
|
81
|
+
|
82
|
+
context 'sudo is true' do
|
83
|
+
let(:subject) { Provisioner::Command::Bootstrap.new(template_configuration, number: '1', ssh_user: 'root', sudo: true) }
|
84
|
+
|
85
|
+
let(:expected_bootstrap_command) { [
|
86
|
+
'knife bootstrap 1.2.3.4',
|
87
|
+
'--distro smartos-base64',
|
88
|
+
'--environment test',
|
89
|
+
'--node-name memcached-sessions001.c1.test',
|
90
|
+
'--run-list role[joyent]',
|
91
|
+
'--ssh-user root',
|
92
|
+
'--sudo',
|
93
|
+
'2>&1 > ./tmp/memcached-sessions001.c1.test_provision.log &'
|
94
|
+
].join(' ') }
|
95
|
+
|
96
|
+
it 'returns command string' do
|
97
|
+
expect(shell_commands[0]).to eq(expected_bootstrap_command)
|
98
|
+
end
|
99
|
+
end
|
64
100
|
end
|
65
101
|
end
|
66
102
|
|
@@ -7,7 +7,7 @@ describe Provisioner::Command::Provision do
|
|
7
7
|
|
8
8
|
context 'host is specified' do
|
9
9
|
|
10
|
-
let(:subject) { Provisioner::Command::Provision.new(template_configuration, '1') }
|
10
|
+
let(:subject) { Provisioner::Command::Provision.new(template_configuration, number: '1') }
|
11
11
|
let(:expected_command) { [
|
12
12
|
'knife joyent server create',
|
13
13
|
'--image 9ec5c0c-a941-11e2-a7dc-57a6b041988f',
|
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.
|
4
|
+
version: 0.3.0
|
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-09-
|
13
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mixlib-cli
|
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
217
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.0.
|
218
|
+
rubygems_version: 2.0.7
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Wrapper gem around provisioning clusters of servers on Joyent cloud
|