ironfan 5.0.11 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/Gemfile +8 -26
- data/Gemfile.lock +38 -41
- data/NOTES-REALM.md +172 -0
- data/Rakefile +19 -77
- data/config/ubuntu12.04-ironfan.erb +7 -0
- data/ironfan.gemspec +28 -225
- data/lib/chef/cluster_knife.rb +26 -0
- data/lib/chef/knife/bootstrap/ubuntu12.04-ironfan.erb +7 -0
- data/lib/chef/knife/cluster_bootstrap.rb +1 -3
- data/lib/chef/knife/cluster_diff.rb +2 -8
- data/lib/chef/knife/cluster_kick.rb +1 -3
- data/lib/chef/knife/cluster_kill.rb +1 -2
- data/lib/chef/knife/cluster_launch.rb +17 -34
- data/lib/chef/knife/cluster_list.rb +6 -5
- data/lib/chef/knife/cluster_proxy.rb +1 -3
- data/lib/chef/knife/cluster_pry.rb +1 -2
- data/lib/chef/knife/cluster_show.rb +6 -7
- data/lib/chef/knife/cluster_ssh.rb +10 -8
- data/lib/chef/knife/cluster_start.rb +1 -2
- data/lib/chef/knife/cluster_stop.rb +1 -2
- data/lib/chef/knife/cluster_sync.rb +2 -3
- data/lib/chef/knife/ironfan_knife_common.rb +58 -18
- data/lib/chef/knife/ironfan_script.rb +0 -3
- data/lib/ironfan/broker/computer.rb +14 -11
- data/lib/ironfan/broker.rb +17 -12
- data/lib/ironfan/cookbook_requirements.rb +155 -0
- data/lib/ironfan/dsl/cloud.rb +2 -0
- data/lib/ironfan/dsl/cluster.rb +25 -15
- data/lib/ironfan/dsl/component.rb +12 -15
- data/lib/ironfan/dsl/compute.rb +10 -8
- data/lib/ironfan/dsl/ec2.rb +2 -26
- data/lib/ironfan/dsl/facet.rb +16 -14
- data/lib/ironfan/dsl/openstack.rb +147 -0
- data/lib/ironfan/dsl/realm.rb +23 -16
- data/lib/ironfan/dsl/security_group.rb +29 -0
- data/lib/ironfan/dsl/server.rb +14 -5
- data/lib/ironfan/dsl/static.rb +63 -0
- data/lib/ironfan/dsl/vsphere.rb +1 -0
- data/lib/ironfan/dsl.rb +1 -134
- data/lib/ironfan/headers.rb +19 -0
- data/lib/ironfan/provider/chef/node.rb +3 -2
- data/lib/ironfan/provider/ec2/machine.rb +10 -14
- data/lib/ironfan/provider/ec2/security_group.rb +58 -43
- data/lib/ironfan/provider/openstack/elastic_ip.rb +96 -0
- data/lib/ironfan/provider/openstack/keypair.rb +78 -0
- data/lib/ironfan/provider/openstack/machine.rb +371 -0
- data/lib/ironfan/provider/openstack/security_group.rb +224 -0
- data/lib/ironfan/provider/openstack.rb +69 -0
- data/lib/ironfan/provider/static/machine.rb +192 -0
- data/lib/ironfan/provider/static.rb +23 -0
- data/lib/ironfan/provider.rb +58 -1
- data/lib/ironfan/requirements.rb +17 -1
- data/lib/ironfan/version.rb +3 -0
- data/lib/ironfan.rb +107 -172
- data/spec/chef/cluster_bootstrap_spec.rb +2 -7
- data/spec/chef/cluster_launch_spec.rb +1 -2
- data/spec/fixtures/realms/samurai.rb +26 -0
- data/spec/integration/minimal-chef-repo/clusters/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/config/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/.gitignore +1 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/certificates/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/client_keys/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/data_bag_keys/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/ec2_certs/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/ec2_keys/.gitkeep +0 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/ironfantest-validator.pem +27 -0
- data/spec/integration/minimal-chef-repo/knife/credentials/ironfantester.pem +27 -0
- data/spec/integration/minimal-chef-repo/tasks/.gitkeep +0 -0
- data/spec/ironfan/cluster_spec.rb +1 -2
- data/spec/ironfan/diff_spec.rb +0 -2
- data/spec/ironfan/dsl_spec.rb +6 -3
- data/spec/ironfan/ec2/cloud_provider_spec.rb +17 -18
- data/spec/ironfan/ec2/elb_spec.rb +44 -41
- data/spec/ironfan/ec2/security_group_spec.rb +45 -47
- data/spec/ironfan/manifest_spec.rb +0 -1
- data/spec/ironfan/plugin_spec.rb +55 -40
- data/spec/ironfan/realm_spec.rb +42 -30
- data/spec/spec_helper.rb +17 -31
- data/spec/{spec_helper → support}/dummy_chef.rb +0 -0
- data/spec/{spec_helper → support}/dummy_diff_drawer.rb +0 -0
- metadata +78 -155
- data/.rspec +0 -2
- data/.yardopts +0 -19
- data/VERSION +0 -2
- data/chefignore +0 -41
- data/notes/Future-development-proposals.md +0 -266
- data/notes/Home.md +0 -55
- data/notes/INSTALL-cloud_setup.md +0 -103
- data/notes/INSTALL.md +0 -134
- data/notes/Ironfan-Roadmap.md +0 -70
- data/notes/Upgrading-to-v4.md +0 -66
- data/notes/advanced-superpowers.md +0 -16
- data/notes/aws_servers.jpg +0 -0
- data/notes/aws_user_key.png +0 -0
- data/notes/cookbook-versioning.md +0 -11
- data/notes/core_concepts.md +0 -200
- data/notes/declaring_volumes.md +0 -3
- data/notes/design_notes-aspect_oriented_devops.md +0 -36
- data/notes/design_notes-ci_testing.md +0 -169
- data/notes/design_notes-cookbook_event_ordering.md +0 -249
- data/notes/design_notes-meta_discovery.md +0 -59
- data/notes/ec2-pricing_and_capacity.md +0 -75
- data/notes/ec2-pricing_and_capacity.numbers +0 -0
- data/notes/homebase-layout.txt +0 -102
- data/notes/knife-cluster-commands.md +0 -21
- data/notes/named-cloud-objects.md +0 -11
- data/notes/opscode_org_key.png +0 -0
- data/notes/opscode_user_key.png +0 -0
- data/notes/philosophy.md +0 -13
- data/notes/rake_tasks.md +0 -24
- data/notes/renamed-recipes.txt +0 -142
- data/notes/silverware.md +0 -85
- data/notes/style_guide.md +0 -300
- data/notes/tips_and_troubleshooting.md +0 -92
- data/notes/walkthrough-hadoop.md +0 -168
- data/notes/walkthrough-web.md +0 -166
- data/spec/fixtures/gunbai.rb +0 -24
- data/spec/test_config.rb +0 -20
- data/tasks/chef_config.rake +0 -38
@@ -1,17 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
cert = IO.read(File.realpath(File.join(File.dirname(__FILE__), '../../fixtures/ec2/elb/snakeoil.crt')))
|
6
|
-
key = IO.read(File.realpath(File.join(File.dirname(__FILE__), '../../fixtures/ec2/elb/snakeoil.key')))
|
3
|
+
cert = File.read Pathname.path_to(:fixtures).join('ec2/elb/snakeoil.crt').to_s
|
4
|
+
key = File.read Pathname.path_to(:fixtures).join('ec2/elb/snakeoil.key').to_s
|
7
5
|
|
8
6
|
describe Ironfan::Dsl::Cluster do
|
9
|
-
let
|
7
|
+
let(:cluster) do
|
10
8
|
|
11
|
-
Ironfan.cluster
|
9
|
+
Ironfan.cluster 'sparky' do
|
12
10
|
|
13
11
|
cloud(:ec2) do
|
14
|
-
iam_server_certificate
|
12
|
+
iam_server_certificate 'snake-oil' do
|
15
13
|
certificate cert
|
16
14
|
private_key key
|
17
15
|
end
|
@@ -21,7 +19,7 @@ describe Ironfan::Dsl::Cluster do
|
|
21
19
|
instances 2
|
22
20
|
cloud(:ec2) do
|
23
21
|
|
24
|
-
elastic_load_balancer
|
22
|
+
elastic_load_balancer 'sparky-elb' do
|
25
23
|
map_port('HTTP', 80, 'HTTP', 81)
|
26
24
|
map_port('HTTPS', 443, 'HTTP', 81, 'snake-oil')
|
27
25
|
disallowed_ciphers %w[ RC4-SHA ]
|
@@ -40,52 +38,57 @@ describe Ironfan::Dsl::Cluster do
|
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
41
|
+
|
42
|
+
Ironfan.cluster('sparky').resolve
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
subject
|
45
|
+
context 'cluster definition' do
|
46
|
+
subject{ cluster }
|
47
47
|
|
48
|
-
its(:name)
|
49
|
-
its(:environment)
|
50
|
-
its(:run_list)
|
48
|
+
its(:name) { should eq('sparky') }
|
49
|
+
its(:environment){ should eq(:_default) }
|
50
|
+
its(:run_list) { should eq([]) }
|
51
51
|
|
52
|
-
it
|
53
|
-
cluster.clouds.values.first.iam_server_certificates.values.length.should
|
52
|
+
it 'has one IAM server certificate' do
|
53
|
+
cluster.clouds.values.first.iam_server_certificates.values.length.should eq(1)
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
context 'facets' do
|
57
|
+
let(:facets){ cluster.facets }
|
58
|
+
|
59
|
+
subject{ facets.values }
|
60
|
+
|
61
|
+
its(:length){ should eq(1) }
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
subject { @facet }
|
64
|
-
its(:name) { should eql "web" }
|
65
|
-
describe "elastic load balancers" do
|
63
|
+
context 'web facet' do
|
64
|
+
subject(:facet){ facets.values.first }
|
66
65
|
|
67
|
-
|
68
|
-
subject { @elb }
|
69
|
-
its(:name) { should eql "sparky-elb" }
|
66
|
+
its(:name){ should eq('web') }
|
70
67
|
|
71
|
-
|
72
|
-
|
68
|
+
context 'elastic load balancer' do
|
69
|
+
|
70
|
+
subject(:elb){ facet.clouds.values.first.elastic_load_balancers.values.first }
|
71
|
+
|
72
|
+
its(:name){ should eq('sparky-elb') }
|
73
|
+
|
74
|
+
it 'has two port mappings' do
|
75
|
+
elb.port_mappings.length.should eq(2)
|
73
76
|
end
|
74
77
|
|
75
|
-
it
|
76
|
-
|
78
|
+
it 'has just one disallowed SSL cipher' do
|
79
|
+
elb.disallowed_ciphers.length.should eq(1)
|
77
80
|
end
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
its(:ping_protocol)
|
83
|
-
its(:ping_port)
|
84
|
-
its(:ping_path)
|
85
|
-
its(:timeout)
|
86
|
-
its(:interval)
|
87
|
-
its(:unhealthy_threshold)
|
88
|
-
its(:healthy_threshold)
|
82
|
+
context 'health check' do
|
83
|
+
subject(:health_check){ elb.health_check }
|
84
|
+
|
85
|
+
its(:ping_protocol) { should eq('HTTP') }
|
86
|
+
its(:ping_port) { should eq(82) }
|
87
|
+
its(:ping_path) { should eq('/healthcheck') }
|
88
|
+
its(:timeout) { should eq(4) }
|
89
|
+
its(:interval) { should eq(10) }
|
90
|
+
its(:unhealthy_threshold){ should eq(3) }
|
91
|
+
its(:healthy_threshold) { should eq(2) }
|
89
92
|
end
|
90
93
|
|
91
94
|
end
|
@@ -1,100 +1,98 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'ironfan'
|
4
|
-
|
5
3
|
describe Ironfan::Dsl::Cluster do
|
6
|
-
let
|
7
|
-
Ironfan.cluster
|
4
|
+
let(:cluster) do
|
5
|
+
Ironfan.cluster 'quirky' do
|
8
6
|
|
9
7
|
cloud(:ec2) do
|
10
|
-
security_group(:ssh).authorize_port_range
|
8
|
+
security_group(:ssh).authorize_port_range(22..22)
|
11
9
|
flavor 't1.micro'
|
12
10
|
end
|
13
11
|
|
14
12
|
facet :web do
|
15
|
-
cloud(:ec2).security_group(
|
13
|
+
cloud(:ec2).security_group('quirky-web').authorize_port_range(80)
|
16
14
|
cloud(:ec2).flavor 'm1.small'
|
17
15
|
end
|
18
16
|
|
19
17
|
facet :mysql do
|
20
18
|
# My what a permissive database you have.
|
21
|
-
cloud(:ec2).security_group(
|
19
|
+
cloud(:ec2).security_group('quirky-mysql').authorize_port_range(3306)
|
22
20
|
cloud(:ec2).flavor 'm1.xlarge'
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
23
|
+
|
24
|
+
Ironfan.cluster('quirky').resolve
|
26
25
|
end
|
27
26
|
|
28
|
-
|
29
|
-
subject
|
27
|
+
context 'cluster definition' do
|
28
|
+
subject{ cluster }
|
29
|
+
|
30
|
+
its(:name) { should eq('quirky') }
|
31
|
+
its(:environment){ should eq(:_default) }
|
32
|
+
its(:run_list) { should eq([]) }
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
its(:run_list) { should eql [] }
|
34
|
+
context 'facets' do
|
35
|
+
let(:facets){ cluster.facets }
|
34
36
|
|
35
|
-
|
36
|
-
before { @facets = cluster.facets }
|
37
|
-
subject { @facets.values }
|
38
|
-
its(:length) { should eql 2 }
|
37
|
+
subject{ facets.values }
|
39
38
|
|
40
|
-
|
41
|
-
before { @facet = @facets.values.first }
|
42
|
-
subject { @facet }
|
43
|
-
its(:name) { should eql "web" }
|
39
|
+
its(:length){ should eq(2) }
|
44
40
|
|
45
|
-
|
46
|
-
|
41
|
+
context 'web facet' do
|
42
|
+
subject(:facet){ facets.values.first }
|
43
|
+
|
44
|
+
its(:name){ should eq('web') }
|
45
|
+
|
46
|
+
it 'has the correct flavor' do
|
47
|
+
facet.cloud(:ec2).flavor.should eq('m1.small')
|
47
48
|
end
|
48
49
|
|
49
|
-
it '
|
50
|
-
|
50
|
+
it 'has the right number of servers' do
|
51
|
+
facet.servers.length.should eq(1)
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
subject { @groups }
|
54
|
+
context 'security groups' do
|
55
|
+
subject(:groups){ facet.clouds.values.first.security_groups.values }
|
56
56
|
|
57
|
-
its(:length)
|
57
|
+
its(:length){ should eq(2) }
|
58
58
|
|
59
59
|
it 'authorizes ssh on port 22 from anywhere' do
|
60
|
-
ssh_auth =
|
60
|
+
ssh_auth = groups.detect{ |g| g.name == 'ssh' }
|
61
61
|
ssh_auth.should_not be_nil
|
62
|
-
ssh_auth.range_authorizations.
|
62
|
+
ssh_auth.range_authorizations.should include([22..22, '0.0.0.0/0', 'tcp'])
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'authorizes HTTP on port 80 from anywhere' do
|
66
|
-
http_auth =
|
66
|
+
http_auth = groups.detect{ |g| g.name == 'quirky-web' }
|
67
67
|
http_auth.should_not be_nil
|
68
|
-
http_auth.range_authorizations.
|
68
|
+
http_auth.range_authorizations.should include([80..80, '0.0.0.0/0', 'tcp'])
|
69
69
|
end
|
70
70
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
subject { @facet }
|
77
|
-
its(:name) { should eql "mysql" }
|
74
|
+
context 'mysql facet' do
|
75
|
+
subject(:facet){ facets.values.last }
|
78
76
|
|
79
|
-
|
80
|
-
|
77
|
+
its(:name){ should eq('mysql') }
|
78
|
+
|
79
|
+
it 'has the correct flavor' do
|
80
|
+
facet.cloud(:ec2).flavor.should eq('m1.xlarge')
|
81
81
|
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
subject { @groups }
|
83
|
+
context 'security groups' do
|
84
|
+
subject(:groups){ facet.clouds.values.first.security_groups.values }
|
86
85
|
|
87
|
-
its(:length)
|
86
|
+
its(:length){ should eq(2) }
|
88
87
|
|
89
88
|
it 'authorizes ssh on port 22 from anywhere' do
|
90
|
-
|
91
|
-
ssh_auth.should_not be_nil
|
89
|
+
groups.one?{ |g| g.name == 'ssh' }.should be_true
|
92
90
|
end
|
93
91
|
|
94
92
|
it 'authorizes MySQL on port 3306 from anywhere' do
|
95
|
-
mysql_auth =
|
93
|
+
mysql_auth = groups.detect{ |g| g.name == 'quirky-mysql' }
|
96
94
|
mysql_auth.should_not be_nil
|
97
|
-
mysql_auth.range_authorizations.
|
95
|
+
mysql_auth.range_authorizations.should include([3306..3306, '0.0.0.0/0', 'tcp'])
|
98
96
|
end
|
99
97
|
|
100
98
|
end
|
data/spec/ironfan/plugin_spec.rb
CHANGED
@@ -1,46 +1,60 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
3
|
+
describe Ironfan::Plugin::Base do
|
4
|
+
|
5
|
+
let(:target_class){ Class.new }
|
6
|
+
let(:plugin_class) do
|
7
|
+
plugin_base = described_class
|
8
|
+
other_class = target_class
|
9
|
+
Class.new do
|
10
|
+
include plugin_base
|
11
|
+
register_with other_class
|
5
12
|
|
6
|
-
|
7
|
-
|
13
|
+
def self.plugin_hook(*_) end
|
14
|
+
end
|
8
15
|
end
|
9
16
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
subject.template(%w[baz bif])
|
16
|
-
end
|
17
|
+
subject(:example_plugin){ plugin_class }
|
18
|
+
|
19
|
+
context '.template' do
|
20
|
+
before(:each){ example_plugin.template %w[baz bif] }
|
17
21
|
|
18
|
-
it '
|
19
|
-
|
22
|
+
it 'defines templates as classes within itself' do
|
23
|
+
example_plugin.const_defined?(:BazBif).should be_true
|
20
24
|
end
|
21
|
-
|
22
|
-
|
25
|
+
|
26
|
+
it 'defines templates as subclasses of itself' do
|
27
|
+
example_plugin.const_get(:BazBif).should be < subject
|
23
28
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
|
30
|
+
it 'allows for customizing class definitions' do
|
31
|
+
example_plugin.template(%w[gig bag]){ def bam() ; end }
|
32
|
+
example_plugin.const_get(:GigBag).new.should respond_to(:bam)
|
28
33
|
end
|
29
|
-
|
30
|
-
|
34
|
+
|
35
|
+
it 'registers methods on the template class' do
|
36
|
+
target_class.new.should respond_to(:baz_bif)
|
31
37
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
|
39
|
+
it 'wires those methods to the plugin_hook method of itself' do
|
40
|
+
target = target_class.new
|
41
|
+
example_plugin.should_receive(:plugin_hook).with(target, {}, :baz, :baz_bif)
|
42
|
+
target.baz_bif
|
36
43
|
end
|
37
|
-
|
38
|
-
|
44
|
+
|
45
|
+
it 'registers the newly created class' do
|
46
|
+
target_class.registry[:baz_bif].should be(example_plugin.const_get(:BazBif))
|
39
47
|
end
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
43
51
|
describe Ironfan::Dsl::Component do
|
52
|
+
|
53
|
+
def uncreate_plugin(plugin_class, target_class)
|
54
|
+
target_class.registry.clear
|
55
|
+
plugin_class.instance_eval{ remove_const :BazBif }
|
56
|
+
end
|
57
|
+
|
44
58
|
before(:each) do
|
45
59
|
Ironfan::Dsl::Component.template(%w[baz bif]) do
|
46
60
|
include Ironfan::Dsl::Component::Announcement
|
@@ -154,7 +168,8 @@ describe Ironfan::Dsl::Component do
|
|
154
168
|
end
|
155
169
|
|
156
170
|
after(:each) do
|
157
|
-
[
|
171
|
+
[
|
172
|
+
:BamServer, :BamClient, :PowServer, :PowClient,
|
158
173
|
:ZapClient, :ZapServer, :BopServer, :BopClient,
|
159
174
|
].each do |class_name|
|
160
175
|
Ironfan::Dsl::Component.send(:remove_const, class_name)
|
@@ -162,28 +177,28 @@ describe Ironfan::Dsl::Component do
|
|
162
177
|
end
|
163
178
|
|
164
179
|
it 'configures the correct security groups during discovery' do
|
165
|
-
foo_group = Ironfan.realm(:wap).cluster(:foo).
|
166
|
-
bar_group = Ironfan.realm(:wap).cluster(:bar).
|
180
|
+
foo_group = Ironfan.realm(:wap).cluster(:foo).security_group('foo')
|
181
|
+
bar_group = Ironfan.realm(:wap).cluster(:bar).security_group('bar')
|
167
182
|
|
168
|
-
foo_group.group_authorized_by.should include('
|
169
|
-
bar_group.group_authorized_by.should include('
|
183
|
+
foo_group.group_authorized_by.should include('bar')
|
184
|
+
bar_group.group_authorized_by.should include('foo')
|
170
185
|
end
|
171
186
|
|
172
187
|
it 'configures the correct security groups during bidirectional discovery' do
|
173
|
-
baz_group = Ironfan.realm(:wap).cluster(:baz).
|
174
|
-
bif_group = Ironfan.realm(:wap).cluster(:bif).
|
188
|
+
baz_group = Ironfan.realm(:wap).cluster(:baz).security_group('baz')
|
189
|
+
bif_group = Ironfan.realm(:wap).cluster(:bif).security_group('bif')
|
175
190
|
|
176
|
-
baz_group.group_authorized_by.should include('
|
177
|
-
baz_group.group_authorized.should include('
|
191
|
+
baz_group.group_authorized_by.should include('bif')
|
192
|
+
baz_group.group_authorized.should include('bif')
|
178
193
|
end
|
179
194
|
|
180
195
|
it 'does not configure extra security groups during bidirectional discovery' do
|
181
|
-
Ironfan.realm(:wap).cluster(:baz).
|
196
|
+
Ironfan.realm(:wap).cluster(:baz).security_groups.keys.should_not include('wap_bif')
|
182
197
|
end
|
183
198
|
|
184
199
|
it 'correctly sets the server cluster even when the client and server facets differ' do
|
185
|
-
bam_wak_group = Ironfan.realm(:wap).cluster(:bam).facet(:wak).
|
186
|
-
bam_wak_group.group_authorized_by.should include('
|
200
|
+
bam_wak_group = Ironfan.realm(:wap).cluster(:bam).facet(:wak).security_group('bam-wak')
|
201
|
+
bam_wak_group.group_authorized_by.should include('bop')
|
187
202
|
end
|
188
203
|
|
189
204
|
end
|
data/spec/ironfan/realm_spec.rb
CHANGED
@@ -1,48 +1,56 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
describe Ironfan::Dsl::Realm do
|
3
|
+
describe Ironfan::Dsl::Realm do
|
6
4
|
before(:each) do
|
7
5
|
(Chef::Config[:ec2_image_info] ||= {}).merge!({
|
8
6
|
%w[us-east-1 64-bit ebs ironfan-precise ] =>
|
9
|
-
{ :
|
7
|
+
{ image_id: 'ami-29fe7640', ssh_user: 'bam', bootstrap_distro: 'ubuntu12.04-ironfan' },
|
10
8
|
})
|
11
9
|
|
12
10
|
Ironfan.realm(:foo) do
|
13
|
-
environment
|
11
|
+
environment :bif
|
14
12
|
|
15
13
|
cloud(:ec2) do
|
16
|
-
flavor
|
17
|
-
image_name
|
14
|
+
flavor 'm1.xlarge'
|
15
|
+
image_name 'ironfan-precise'
|
18
16
|
end
|
19
17
|
|
20
18
|
cluster(:bar) do
|
21
19
|
cluster_role.override_attributes(a: 1)
|
20
|
+
|
22
21
|
facet(:baz) do
|
23
22
|
instances 1
|
24
|
-
role
|
23
|
+
role :blah
|
25
24
|
facet_role.override_attributes(b: 1)
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
Ironfan.
|
30
|
+
after(:each) do
|
31
|
+
Ironfan.clusters.clear
|
32
|
+
Ironfan.realms.clear
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
Ironfan.
|
35
|
+
def manifest
|
36
|
+
Ironfan.cluster(:bar).resolve.facets[:baz].server(0).to_machine_manifest
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
40
|
-
Ironfan
|
39
|
+
it 'chooses its own name as its default environment' do
|
40
|
+
Ironfan.realm(:bar){ }.environment.to_s.should == 'bar'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'chooses the widest possible cookbook contraints to satisfy all plugins' do
|
44
|
+
Ironfan::Dsl::Component.template(%w[jib jab]) do
|
45
|
+
require_strict_versioning false
|
46
|
+
|
41
47
|
cookbook_req 'bif', '>= 1.0.0'
|
42
48
|
def project(_) end
|
43
49
|
end
|
44
50
|
|
45
|
-
Ironfan::Dsl::Component.template(%w[
|
51
|
+
Ironfan::Dsl::Component.template(%w[dig dug]) do
|
52
|
+
require_strict_versioning false
|
53
|
+
|
46
54
|
cookbook_req 'bif', '>= 2.0.0'
|
47
55
|
def project(_) end
|
48
56
|
end
|
@@ -50,20 +58,24 @@ describe Ironfan::Dsl::Realm do
|
|
50
58
|
Ironfan.realm(:qux) do
|
51
59
|
cluster(:cuz) do
|
52
60
|
facet(:lix) do
|
53
|
-
|
54
|
-
|
61
|
+
jib_jab
|
62
|
+
dig_dug
|
55
63
|
end
|
56
64
|
end
|
57
65
|
end.cookbook_reqs['bif'].should == '>= 2.0.0'
|
58
66
|
end
|
59
67
|
|
60
|
-
it '
|
68
|
+
it 'complains when no cookbook constraints can satisfy all plugins' do
|
61
69
|
Ironfan::Dsl::Component.template(%w[bam pow]) do
|
70
|
+
require_strict_versioning false
|
71
|
+
|
62
72
|
cookbook_req 'bif', '~> 1.0.0'
|
63
73
|
def project(_) end
|
64
74
|
end
|
65
75
|
|
66
76
|
Ironfan::Dsl::Component.template(%w[jam wam]) do
|
77
|
+
require_strict_versioning false
|
78
|
+
|
67
79
|
cookbook_req 'bif', '>= 2.0.0'
|
68
80
|
def project(_) end
|
69
81
|
end
|
@@ -80,10 +92,10 @@ describe Ironfan::Dsl::Realm do
|
|
80
92
|
expect{ Ironfan.realm(:qux).cookbook_reqs }.to raise_error
|
81
93
|
end
|
82
94
|
|
83
|
-
it '
|
84
|
-
|
95
|
+
it 'creates clusters that can be referenced later' do
|
96
|
+
test_scope = self
|
85
97
|
Ironfan.realm :xx do
|
86
|
-
cluster(:bar).should
|
98
|
+
cluster(:bar).should test_scope.be(cluster(:bar))
|
87
99
|
end
|
88
100
|
end
|
89
101
|
|
@@ -93,22 +105,22 @@ describe Ironfan::Dsl::Realm do
|
|
93
105
|
cluster(:baz){ facet :bif }
|
94
106
|
end
|
95
107
|
|
96
|
-
Ironfan.cluster(:
|
97
|
-
Ironfan.cluster(:
|
108
|
+
Ironfan.cluster(:baz).facets.to_a.should_not(be_empty)
|
109
|
+
Ironfan.cluster(:baz).servers.to_a.first.should_not(be_nil)
|
98
110
|
end
|
99
111
|
|
100
112
|
it 'should create clusters with names prefixed by its own' do
|
101
|
-
Ironfan.cluster(:
|
113
|
+
Ironfan.cluster(:bar).should_not(be_nil)
|
102
114
|
end
|
103
115
|
|
104
116
|
it 'should create clusters with machines' do
|
105
|
-
Ironfan.cluster(:
|
117
|
+
Ironfan.cluster(:bar).facets[:baz].server(0).should_not(be_nil)
|
106
118
|
end
|
107
119
|
|
108
|
-
it 'should create clusters with attributes correctly applied' do
|
120
|
+
it 'should create clusters with attributes correctly applied' do
|
109
121
|
manifest.cluster_override_attributes.should == {a: 1}
|
110
122
|
manifest.facet_override_attributes.should == {b: 1}
|
111
|
-
manifest.run_list.should == %w[role[blah] role[
|
123
|
+
manifest.run_list.should == %w[role[blah] role[bar-cluster] role[bar-baz-facet]]
|
112
124
|
end
|
113
125
|
|
114
126
|
it 'should create clusters with the correct ssh user' do
|
@@ -118,7 +130,7 @@ describe Ironfan::Dsl::Realm do
|
|
118
130
|
|
119
131
|
it 'should save cloud properties to be shared among all clusters within the realm' do
|
120
132
|
# We need to resolve before the cloud settings come through
|
121
|
-
Ironfan.realm(:foo).clusters[:
|
133
|
+
Ironfan.realm(:foo).clusters[:bar].resolve.facets[:baz].servers.to_a.first.to_machine_manifest.flavor.should == 'm1.xlarge'
|
122
134
|
|
123
135
|
# Ironfan.cluster will do the resolution for us.
|
124
136
|
manifest.flavor.should == 'm1.xlarge'
|
@@ -126,12 +138,12 @@ describe Ironfan::Dsl::Realm do
|
|
126
138
|
|
127
139
|
it 'should save an environment to be shared among all clusters within the realm' do
|
128
140
|
# We need to resolve before the cloud settings come through
|
129
|
-
Ironfan.realm(:foo).clusters[:
|
141
|
+
Ironfan.realm(:foo).resolve.clusters[:bar].facets[:baz].environment.should == :bif
|
130
142
|
|
131
143
|
# The server manifest should contain the environment.
|
132
144
|
manifest.environment.should == :bif
|
133
145
|
|
134
146
|
# Ironfan.cluster will do the resolution for us.
|
135
|
-
Ironfan.cluster(:
|
147
|
+
Ironfan.cluster(:bar).resolve.facets[:baz].environment.should == :bif
|
136
148
|
end
|
137
149
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,53 +1,39 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
1
|
+
if ENV['IRONFAN_COV']
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
end
|
5
|
+
|
4
6
|
require 'ironfan'
|
7
|
+
require 'chef/cluster_knife'
|
5
8
|
require 'fog'
|
6
9
|
Fog.mock!
|
7
10
|
Fog::Mock.delay = 0
|
8
11
|
|
9
12
|
require 'gorillib/pathname'
|
10
13
|
|
11
|
-
Pathname.register_paths(
|
12
|
-
|
13
|
-
|
14
|
-
)
|
14
|
+
Pathname.register_paths(code: File.expand_path('../..', __FILE__),
|
15
|
+
spec: [:code, 'spec'],
|
16
|
+
fixtures: [:spec, 'fixtures'],
|
17
|
+
support: [:spec, 'support'])
|
18
|
+
|
19
|
+
Dir[Pathname.path_to(:support).join('**/*.rb')].each{ |f| require f }
|
15
20
|
|
16
21
|
RSpec.configure do |cfg|
|
17
22
|
def ironfan_go!
|
18
23
|
k = Chef::Knife.new
|
19
|
-
k.config[:config_file] = Pathname.path_to(:fixtures, 'knife/knife.rb')
|
24
|
+
k.config[:config_file] = Pathname.path_to(:fixtures, 'knife/knife.rb').to_s
|
20
25
|
k.configure_chef
|
21
26
|
Chef::Config.instance_eval do
|
22
|
-
knife.merge!(
|
23
|
-
|
24
|
-
|
25
|
-
})
|
26
|
-
cluster_path Pathname.path_to(:fixtures).to_s
|
27
|
+
knife.merge!(aws_access_key_id: 'access_key',
|
28
|
+
aws_secret_access_key: 'secret')
|
29
|
+
cluster_path Pathname.path_to(:fixtures).join('clusters').to_s
|
27
30
|
end
|
28
31
|
|
29
|
-
require 'ironfan'
|
30
|
-
|
31
32
|
Ironfan.ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {})
|
32
|
-
Ironfan.
|
33
|
-
Ironfan.cluster_path
|
33
|
+
Ironfan.knife_config = k.config
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
require 'chef_zero/server'
|
38
38
|
server = ChefZero::Server.new(port: 4000)
|
39
39
|
server.start_background
|
40
|
-
|
41
|
-
def uncreate_plugin(plugin_class, target_class)
|
42
|
-
target_class.registry.clear
|
43
|
-
plugin_class.instance_eval{ remove_const :BazBif }
|
44
|
-
end
|
45
|
-
|
46
|
-
class Foo
|
47
|
-
end
|
48
|
-
|
49
|
-
class MyPlugin
|
50
|
-
include Ironfan::Plugin::Base; register_with Foo
|
51
|
-
|
52
|
-
def self.plugin_hook(*_) end
|
53
|
-
end
|
File without changes
|
File without changes
|