ridley 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +46 -1
- data/Guardfile +0 -1
- data/README.md +15 -0
- data/Thorfile +18 -15
- data/bootstrappers/omnibus.erb +73 -0
- data/lib/ridley/bootstrapper/context.rb +172 -0
- data/lib/ridley/bootstrapper.rb +99 -0
- data/lib/ridley/chain_link.rb +25 -0
- data/lib/ridley/connection.rb +27 -5
- data/lib/ridley/errors.rb +6 -1
- data/lib/ridley/logging.rb +30 -0
- data/lib/ridley/resources/client.rb +3 -3
- data/lib/ridley/resources/cookbook.rb +3 -3
- data/lib/ridley/resources/data_bag.rb +8 -8
- data/lib/ridley/resources/environment.rb +3 -3
- data/lib/ridley/resources/node.rb +57 -3
- data/lib/ridley/resources/role.rb +3 -3
- data/lib/ridley/resources/sandbox.rb +3 -3
- data/lib/ridley/ssh/response.rb +13 -0
- data/lib/ridley/ssh/response_set.rb +51 -0
- data/lib/ridley/ssh/worker.rb +71 -0
- data/lib/ridley/ssh.rb +74 -0
- data/lib/ridley/version.rb +1 -1
- data/lib/ridley.rb +42 -17
- data/ridley.gemspec +6 -17
- data/spec/acceptance/bootstrapping_spec.rb +29 -0
- data/spec/spec_helper.rb +19 -3
- data/spec/unit/ridley/bootstrapper/context_spec.rb +119 -0
- data/spec/unit/ridley/bootstrapper_spec.rb +86 -0
- data/spec/unit/ridley/resources/node_spec.rb +41 -1
- data/spec/unit/ridley/ssh_spec.rb +31 -0
- data/spec/unit/ridley_spec.rb +0 -6
- metadata +42 -185
- data/lib/ridley/context.rb +0 -25
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ridley::Bootstrapper::Context do
|
4
|
+
let(:host) { "reset.riotgames.com" }
|
5
|
+
|
6
|
+
let(:options) do
|
7
|
+
{
|
8
|
+
server_url: "https://api.opscode.com/organizations/vialstudios",
|
9
|
+
validator_client: "chef-validator",
|
10
|
+
validator_path: fixtures_path.join("reset.pem").to_s,
|
11
|
+
encrypted_data_bag_secret_path: fixtures_path.join("reset.pem").to_s
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "ClassMethods" do
|
16
|
+
subject { Ridley::Bootstrapper::Context }
|
17
|
+
|
18
|
+
describe "::new" do
|
19
|
+
context "when validator_path is not specified" do
|
20
|
+
let(:options) { Hash.new }
|
21
|
+
|
22
|
+
it "raises an ArgumentError" do
|
23
|
+
lambda {
|
24
|
+
subject.new(host, options)
|
25
|
+
}.should raise_error(Ridley::Errors::ArgumentError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when a validator_path is specified" do
|
30
|
+
let(:options) do
|
31
|
+
{
|
32
|
+
server_url: "https://api.opscode.com/organizations/vialstudios",
|
33
|
+
validator_path: fixtures_path.join("reset.pem").to_s
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "sets a value for validation_key" do
|
38
|
+
subject.new(host, options).validation_key.should_not be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
subject { Ridley::Bootstrapper::Context.new(host, options) }
|
45
|
+
|
46
|
+
describe "#boot_command" do
|
47
|
+
it "returns a string" do
|
48
|
+
subject.boot_command.should be_a(String)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#chef_run" do
|
53
|
+
it "returns a string" do
|
54
|
+
subject.chef_run.should be_a(String)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#chef_config" do
|
59
|
+
it "returns a string" do
|
60
|
+
subject.chef_config.should be_a(String)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#first_boot" do
|
65
|
+
it "returns a string" do
|
66
|
+
subject.first_boot.should be_a(String)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#validation_key" do
|
71
|
+
it "returns a string" do
|
72
|
+
subject.validation_key.should be_a(String)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns the chomped contents of the file found at validator_path" do
|
76
|
+
subject.validation_key.should eql(File.read(options[:validator_path]).chomp)
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when a validator file is not found at validator_path" do
|
80
|
+
before(:each) do
|
81
|
+
subject.stub(:validator_path) { fixtures_path.join("not.txt").to_s }
|
82
|
+
end
|
83
|
+
|
84
|
+
it "raises a ValidatorNotFound error" do
|
85
|
+
lambda {
|
86
|
+
subject.validation_key
|
87
|
+
}.should raise_error(Ridley::Errors::ValidatorNotFound)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#encrypted_data_bag_secret" do
|
93
|
+
it "returns a string" do
|
94
|
+
subject.encrypted_data_bag_secret.should be_a(String)
|
95
|
+
end
|
96
|
+
|
97
|
+
context "when a encrypted_data_bag_secret_path is not provided" do
|
98
|
+
before(:each) do
|
99
|
+
subject.stub(:encrypted_data_bag_secret_path) { nil }
|
100
|
+
end
|
101
|
+
|
102
|
+
it "returns nil" do
|
103
|
+
subject.encrypted_data_bag_secret.should be_nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when the file is not found at the given encrypted_data_bag_secret_path" do
|
108
|
+
before(:each) do
|
109
|
+
subject.stub(:encrypted_data_bag_secret_path) { fixtures_path.join("not.txt").to_s }
|
110
|
+
end
|
111
|
+
|
112
|
+
it "raises an EncryptedDataBagSecretNotFound erorr" do
|
113
|
+
lambda {
|
114
|
+
subject.encrypted_data_bag_secret
|
115
|
+
}.should raise_error(Ridley::Errors::EncryptedDataBagSecretNotFound)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ridley::Bootstrapper do
|
4
|
+
let(:nodes) do
|
5
|
+
[
|
6
|
+
"33.33.33.10"
|
7
|
+
]
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:options) do
|
11
|
+
{
|
12
|
+
ssh_user: "vagrant",
|
13
|
+
ssh_password: "vagrant",
|
14
|
+
server_url: "https://api.opscode.com/organizations/vialstudios",
|
15
|
+
validator_client: "vialstudios-validator",
|
16
|
+
validator_path: fixtures_path.join("reset.pem").to_s,
|
17
|
+
encrypted_data_bag_secret_path: fixtures_path.join("reset.pem").to_s
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "ClassMethods" do
|
22
|
+
subject { Ridley::Bootstrapper }
|
23
|
+
|
24
|
+
describe "::new" do
|
25
|
+
context "given a single string for nodes" do
|
26
|
+
before(:each) do
|
27
|
+
@obj = subject.new("33.33.33.10", options)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has one node" do
|
31
|
+
@obj.hosts.should have(1).item
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has one context" do
|
35
|
+
@obj.contexts.should have(1).item
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "given an an array of strings nodes" do
|
40
|
+
before(:each) do
|
41
|
+
@obj = subject.new(["33.33.33.10", "33.33.33.11"], options)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "has a host for each item given" do
|
45
|
+
@obj.hosts.should have(2).items
|
46
|
+
end
|
47
|
+
|
48
|
+
it "has a context for each item given" do
|
49
|
+
@obj.contexts.should have(2).items
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "::templates_path" do
|
55
|
+
it "returns a pathname" do
|
56
|
+
subject.templates_path.should be_a(Pathname)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "::default_template" do
|
61
|
+
it "returns a string" do
|
62
|
+
subject.default_template.should be_a(String)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
subject { Ridley::Bootstrapper.new(nodes, options) }
|
68
|
+
|
69
|
+
describe "#hosts" do
|
70
|
+
it "returns an array of strings" do
|
71
|
+
subject.hosts.should be_a(Array)
|
72
|
+
subject.hosts.should each be_a(String)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#contexts" do
|
77
|
+
it "returns an array of Bootstrapper::Contexts" do
|
78
|
+
subject.contexts.should be_a(Array)
|
79
|
+
subject.contexts.should each be_a(Ridley::Bootstrapper::Context)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#run" do
|
84
|
+
pending
|
85
|
+
end
|
86
|
+
end
|
@@ -3,7 +3,39 @@ require 'spec_helper'
|
|
3
3
|
describe Ridley::Node do
|
4
4
|
it_behaves_like "a Ridley Resource", Ridley::Node
|
5
5
|
|
6
|
-
let(:connection)
|
6
|
+
let(:connection) do
|
7
|
+
double('conn',
|
8
|
+
server_url: "https://api.opscode.com/organizations/vialstudios",
|
9
|
+
validator_client: "chef-validator",
|
10
|
+
ssh: {
|
11
|
+
user: "reset",
|
12
|
+
password: "lol"
|
13
|
+
}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "ClassMethods" do
|
18
|
+
subject { Ridley::Node }
|
19
|
+
|
20
|
+
describe "::bootstrap" do
|
21
|
+
let(:boot_options) do
|
22
|
+
{
|
23
|
+
validator_path: fixtures_path.join("reset.pem").to_s,
|
24
|
+
encrypted_data_bag_secret_path: fixtures_path.join("reset.pem").to_s
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
it "bootstraps a single node" do
|
29
|
+
pending
|
30
|
+
subject.bootstrap(connection, "33.33.33.10", boot_options)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "bootstraps multiple nodes" do
|
34
|
+
pending
|
35
|
+
subject.bootstrap(connection, "33.33.33.10", "33.33.33.11", boot_options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
7
39
|
|
8
40
|
subject { Ridley::Node.new(connection) }
|
9
41
|
|
@@ -245,4 +277,12 @@ describe Ridley::Node do
|
|
245
277
|
subject.public_hostname.should eql("reset.internal.riotgames.com")
|
246
278
|
end
|
247
279
|
end
|
280
|
+
|
281
|
+
describe "#chef_solo" do
|
282
|
+
pending
|
283
|
+
end
|
284
|
+
|
285
|
+
describe "#chef_client" do
|
286
|
+
pending
|
287
|
+
end
|
248
288
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ridley::SSH do
|
4
|
+
let(:connection) { double('conn', ssh: { user: "vagrant", password: "vagrant" }) }
|
5
|
+
|
6
|
+
let(:node_one) do
|
7
|
+
Ridley::Node.new(connection, automatic: { cloud: { public_hostname: "33.33.33.10" } })
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:node_two) do
|
11
|
+
Ridley::Node.new(connection, automatic: { cloud: { public_hostname: "33.33.33.11" } })
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "ClassMethods" do
|
15
|
+
subject { Ridley::SSH }
|
16
|
+
|
17
|
+
describe "::start" do
|
18
|
+
pending
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
subject { Ridley::SSH.new([node_one, node_two], user: "vagrant", password: "vagrant") }
|
23
|
+
|
24
|
+
describe "#workers" do
|
25
|
+
pending
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#run" do
|
29
|
+
pending
|
30
|
+
end
|
31
|
+
end
|
data/spec/unit/ridley_spec.rb
CHANGED