ironfan 5.0.11 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +8 -26
  4. data/Gemfile.lock +38 -41
  5. data/NOTES-REALM.md +172 -0
  6. data/Rakefile +19 -77
  7. data/config/ubuntu12.04-ironfan.erb +7 -0
  8. data/ironfan.gemspec +28 -225
  9. data/lib/chef/cluster_knife.rb +26 -0
  10. data/lib/chef/knife/bootstrap/ubuntu12.04-ironfan.erb +7 -0
  11. data/lib/chef/knife/cluster_bootstrap.rb +1 -3
  12. data/lib/chef/knife/cluster_diff.rb +2 -8
  13. data/lib/chef/knife/cluster_kick.rb +1 -3
  14. data/lib/chef/knife/cluster_kill.rb +1 -2
  15. data/lib/chef/knife/cluster_launch.rb +17 -34
  16. data/lib/chef/knife/cluster_list.rb +6 -5
  17. data/lib/chef/knife/cluster_proxy.rb +1 -3
  18. data/lib/chef/knife/cluster_pry.rb +1 -2
  19. data/lib/chef/knife/cluster_show.rb +6 -7
  20. data/lib/chef/knife/cluster_ssh.rb +10 -8
  21. data/lib/chef/knife/cluster_start.rb +1 -2
  22. data/lib/chef/knife/cluster_stop.rb +1 -2
  23. data/lib/chef/knife/cluster_sync.rb +2 -3
  24. data/lib/chef/knife/ironfan_knife_common.rb +58 -18
  25. data/lib/chef/knife/ironfan_script.rb +0 -3
  26. data/lib/ironfan/broker/computer.rb +14 -11
  27. data/lib/ironfan/broker.rb +17 -12
  28. data/lib/ironfan/cookbook_requirements.rb +155 -0
  29. data/lib/ironfan/dsl/cloud.rb +2 -0
  30. data/lib/ironfan/dsl/cluster.rb +25 -15
  31. data/lib/ironfan/dsl/component.rb +12 -15
  32. data/lib/ironfan/dsl/compute.rb +10 -8
  33. data/lib/ironfan/dsl/ec2.rb +2 -26
  34. data/lib/ironfan/dsl/facet.rb +16 -14
  35. data/lib/ironfan/dsl/openstack.rb +147 -0
  36. data/lib/ironfan/dsl/realm.rb +23 -16
  37. data/lib/ironfan/dsl/security_group.rb +29 -0
  38. data/lib/ironfan/dsl/server.rb +14 -5
  39. data/lib/ironfan/dsl/static.rb +63 -0
  40. data/lib/ironfan/dsl/vsphere.rb +1 -0
  41. data/lib/ironfan/dsl.rb +1 -134
  42. data/lib/ironfan/headers.rb +19 -0
  43. data/lib/ironfan/provider/chef/node.rb +3 -2
  44. data/lib/ironfan/provider/ec2/machine.rb +10 -14
  45. data/lib/ironfan/provider/ec2/security_group.rb +58 -43
  46. data/lib/ironfan/provider/openstack/elastic_ip.rb +96 -0
  47. data/lib/ironfan/provider/openstack/keypair.rb +78 -0
  48. data/lib/ironfan/provider/openstack/machine.rb +371 -0
  49. data/lib/ironfan/provider/openstack/security_group.rb +224 -0
  50. data/lib/ironfan/provider/openstack.rb +69 -0
  51. data/lib/ironfan/provider/static/machine.rb +192 -0
  52. data/lib/ironfan/provider/static.rb +23 -0
  53. data/lib/ironfan/provider.rb +58 -1
  54. data/lib/ironfan/requirements.rb +17 -1
  55. data/lib/ironfan/version.rb +3 -0
  56. data/lib/ironfan.rb +107 -172
  57. data/spec/chef/cluster_bootstrap_spec.rb +2 -7
  58. data/spec/chef/cluster_launch_spec.rb +1 -2
  59. data/spec/fixtures/realms/samurai.rb +26 -0
  60. data/spec/integration/minimal-chef-repo/clusters/.gitkeep +0 -0
  61. data/spec/integration/minimal-chef-repo/config/.gitkeep +0 -0
  62. data/spec/integration/minimal-chef-repo/knife/credentials/.gitignore +1 -0
  63. data/spec/integration/minimal-chef-repo/knife/credentials/certificates/.gitkeep +0 -0
  64. data/spec/integration/minimal-chef-repo/knife/credentials/client_keys/.gitkeep +0 -0
  65. data/spec/integration/minimal-chef-repo/knife/credentials/data_bag_keys/.gitkeep +0 -0
  66. data/spec/integration/minimal-chef-repo/knife/credentials/ec2_certs/.gitkeep +0 -0
  67. data/spec/integration/minimal-chef-repo/knife/credentials/ec2_keys/.gitkeep +0 -0
  68. data/spec/integration/minimal-chef-repo/knife/credentials/ironfantest-validator.pem +27 -0
  69. data/spec/integration/minimal-chef-repo/knife/credentials/ironfantester.pem +27 -0
  70. data/spec/integration/minimal-chef-repo/tasks/.gitkeep +0 -0
  71. data/spec/ironfan/cluster_spec.rb +1 -2
  72. data/spec/ironfan/diff_spec.rb +0 -2
  73. data/spec/ironfan/dsl_spec.rb +6 -3
  74. data/spec/ironfan/ec2/cloud_provider_spec.rb +17 -18
  75. data/spec/ironfan/ec2/elb_spec.rb +44 -41
  76. data/spec/ironfan/ec2/security_group_spec.rb +45 -47
  77. data/spec/ironfan/manifest_spec.rb +0 -1
  78. data/spec/ironfan/plugin_spec.rb +55 -40
  79. data/spec/ironfan/realm_spec.rb +42 -30
  80. data/spec/spec_helper.rb +17 -31
  81. data/spec/{spec_helper → support}/dummy_chef.rb +0 -0
  82. data/spec/{spec_helper → support}/dummy_diff_drawer.rb +0 -0
  83. metadata +78 -155
  84. data/.rspec +0 -2
  85. data/.yardopts +0 -19
  86. data/VERSION +0 -2
  87. data/chefignore +0 -41
  88. data/notes/Future-development-proposals.md +0 -266
  89. data/notes/Home.md +0 -55
  90. data/notes/INSTALL-cloud_setup.md +0 -103
  91. data/notes/INSTALL.md +0 -134
  92. data/notes/Ironfan-Roadmap.md +0 -70
  93. data/notes/Upgrading-to-v4.md +0 -66
  94. data/notes/advanced-superpowers.md +0 -16
  95. data/notes/aws_servers.jpg +0 -0
  96. data/notes/aws_user_key.png +0 -0
  97. data/notes/cookbook-versioning.md +0 -11
  98. data/notes/core_concepts.md +0 -200
  99. data/notes/declaring_volumes.md +0 -3
  100. data/notes/design_notes-aspect_oriented_devops.md +0 -36
  101. data/notes/design_notes-ci_testing.md +0 -169
  102. data/notes/design_notes-cookbook_event_ordering.md +0 -249
  103. data/notes/design_notes-meta_discovery.md +0 -59
  104. data/notes/ec2-pricing_and_capacity.md +0 -75
  105. data/notes/ec2-pricing_and_capacity.numbers +0 -0
  106. data/notes/homebase-layout.txt +0 -102
  107. data/notes/knife-cluster-commands.md +0 -21
  108. data/notes/named-cloud-objects.md +0 -11
  109. data/notes/opscode_org_key.png +0 -0
  110. data/notes/opscode_user_key.png +0 -0
  111. data/notes/philosophy.md +0 -13
  112. data/notes/rake_tasks.md +0 -24
  113. data/notes/renamed-recipes.txt +0 -142
  114. data/notes/silverware.md +0 -85
  115. data/notes/style_guide.md +0 -300
  116. data/notes/tips_and_troubleshooting.md +0 -92
  117. data/notes/walkthrough-hadoop.md +0 -168
  118. data/notes/walkthrough-web.md +0 -166
  119. data/spec/fixtures/gunbai.rb +0 -24
  120. data/spec/test_config.rb +0 -20
  121. data/tasks/chef_config.rake +0 -38
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
- require 'ironfan'
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 (:cluster) do
7
+ let(:cluster) do
10
8
 
11
- Ironfan.cluster "sparky" do
9
+ Ironfan.cluster 'sparky' do
12
10
 
13
11
  cloud(:ec2) do
14
- iam_server_certificate "snake-oil" do
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 "sparky-elb" do
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
- describe 'cluster definition' do
46
- subject { cluster }
45
+ context 'cluster definition' do
46
+ subject{ cluster }
47
47
 
48
- its(:name) { should eql "sparky" }
49
- its(:environment) { should eql :_default }
50
- its(:run_list) { should eql [] }
48
+ its(:name) { should eq('sparky') }
49
+ its(:environment){ should eq(:_default) }
50
+ its(:run_list) { should eq([]) }
51
51
 
52
- it "should have one IAM server certificate" do
53
- cluster.clouds.values.first.iam_server_certificates.values.length.should == 1
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
- describe 'facets' do
57
- before { @facets = cluster.facets }
58
- subject { @facets.values }
59
- its(:length) { should eql 1 }
56
+ context 'facets' do
57
+ let(:facets){ cluster.facets }
58
+
59
+ subject{ facets.values }
60
+
61
+ its(:length){ should eq(1) }
60
62
 
61
- describe 'web facet' do
62
- before { @facet = @facets.values.first }
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
- before { @elb = @facet.clouds.values.first.elastic_load_balancers.values.first }
68
- subject { @elb }
69
- its(:name) { should eql "sparky-elb" }
66
+ its(:name){ should eq('web') }
70
67
 
71
- it "should have two port mappings" do
72
- @elb.port_mappings.length.should == 2
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 "should have just one disallowed SSL cipher" do
76
- @elb.disallowed_ciphers.length.should == 1
78
+ it 'has just one disallowed SSL cipher' do
79
+ elb.disallowed_ciphers.length.should eq(1)
77
80
  end
78
81
 
79
- describe "health check" do
80
- before { @hc = @elb.health_check }
81
- subject { @hc }
82
- its(:ping_protocol) { should eql 'HTTP' }
83
- its(:ping_port) { should eql 82 }
84
- its(:ping_path) { should eql '/healthcheck' }
85
- its(:timeout) { should eql 4 }
86
- its(:interval) { should eql 10 }
87
- its(:unhealthy_threshold) { should eql 3 }
88
- its(:healthy_threshold) { should eql 2 }
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 (:cluster) do
7
- Ironfan.cluster "sparky" do
4
+ let(:cluster) do
5
+ Ironfan.cluster 'quirky' do
8
6
 
9
7
  cloud(:ec2) do
10
- security_group(:ssh).authorize_port_range 22..22
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("sparky-web").authorize_port_range(80)
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("sparky-mysql").authorize_port_range(3306)
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
- describe 'cluster definition' do
29
- subject { cluster }
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
- its(:name) { should eql "sparky" }
32
- its(:environment) { should eql :_default }
33
- its(:run_list) { should eql [] }
34
+ context 'facets' do
35
+ let(:facets){ cluster.facets }
34
36
 
35
- describe 'facets' do
36
- before { @facets = cluster.facets }
37
- subject { @facets.values }
38
- its(:length) { should eql 2 }
37
+ subject{ facets.values }
39
38
 
40
- describe 'web facet' do
41
- before { @facet = @facets.values.first }
42
- subject { @facet }
43
- its(:name) { should eql "web" }
39
+ its(:length){ should eq(2) }
44
40
 
45
- it 'should have the correct flavor' do
46
- @facet.cloud(:ec2).flavor.should == 'm1.small'
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 'should have the right number of servers' do
50
- @facet.servers.length.should == 1
50
+ it 'has the right number of servers' do
51
+ facet.servers.length.should eq(1)
51
52
  end
52
53
 
53
- describe 'security groups' do
54
- before { @groups = @facet.clouds.values.first.security_groups.values }
55
- subject { @groups }
54
+ context 'security groups' do
55
+ subject(:groups){ facet.clouds.values.first.security_groups.values }
56
56
 
57
- its(:length) { should eql 2 }
57
+ its(:length){ should eq(2) }
58
58
 
59
59
  it 'authorizes ssh on port 22 from anywhere' do
60
- ssh_auth = @groups.detect { |g| g.name == 'ssh' }
60
+ ssh_auth = groups.detect{ |g| g.name == 'ssh' }
61
61
  ssh_auth.should_not be_nil
62
- ssh_auth.range_authorizations.select { |g| g.eql? [22..22, "0.0.0.0/0", "tcp"] }.should_not be_empty
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 = @groups.detect { |g| g.name == 'sparky-web' }
66
+ http_auth = groups.detect{ |g| g.name == 'quirky-web' }
67
67
  http_auth.should_not be_nil
68
- http_auth.range_authorizations.select { |g| g.eql? [80..80, "0.0.0.0/0", "tcp"] }.should_not be_empty
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
- describe 'mysql facet' do
75
- before { @facet = @facets.values.last }
76
- subject { @facet }
77
- its(:name) { should eql "mysql" }
74
+ context 'mysql facet' do
75
+ subject(:facet){ facets.values.last }
78
76
 
79
- it 'should have the correct flavor' do
80
- @facet.cloud(:ec2).flavor.should == 'm1.xlarge'
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
- describe 'security groups' do
84
- before { @groups = @facet.clouds.values.first.security_groups.values }
85
- subject { @groups }
83
+ context 'security groups' do
84
+ subject(:groups){ facet.clouds.values.first.security_groups.values }
86
85
 
87
- its(:length) { should eql 2 }
86
+ its(:length){ should eq(2) }
88
87
 
89
88
  it 'authorizes ssh on port 22 from anywhere' do
90
- ssh_auth = @groups.detect { |g| g.name == 'ssh' }
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 = @groups.detect { |g| g.name == 'sparky-mysql' }
93
+ mysql_auth = groups.detect{ |g| g.name == 'quirky-mysql' }
96
94
  mysql_auth.should_not be_nil
97
- mysql_auth.range_authorizations.select { |g| g.eql? [3306..3306, "0.0.0.0/0", "tcp"] }.should_not be_empty
95
+ mysql_auth.range_authorizations.should include([3306..3306, '0.0.0.0/0', 'tcp'])
98
96
  end
99
97
 
100
98
  end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'ironfan'
3
2
 
4
3
  describe Ironfan::Dsl::MachineManifest do
5
4
  context 'it disregards whether values are strings or symbols' do
@@ -1,46 +1,60 @@
1
- require_relative '../spec_helper.rb'
1
+ require 'spec_helper.rb'
2
2
 
3
- describe MyPlugin do
4
- subject { MyPlugin }
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
- it 'should respond to template' do
7
- subject.should(respond_to(:template))
13
+ def self.plugin_hook(*_) end
14
+ end
8
15
  end
9
16
 
10
- context 'when templatizing plugins' do
11
- after(:each) do
12
- uncreate_plugin(subject, Foo)
13
- end
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 'should create them as classes within itself' do
19
- subject.constants.should(include(:BazBif))
22
+ it 'defines templates as classes within itself' do
23
+ example_plugin.const_defined?(:BazBif).should be_true
20
24
  end
21
- it 'should create them as subclasses of itself' do
22
- subject.const_get(:BazBif).should(be < subject)
25
+
26
+ it 'defines templates as subclasses of itself' do
27
+ example_plugin.const_get(:BazBif).should be < subject
23
28
  end
24
- it 'should allow customizing the classes' do
25
- uncreate_plugin(subject, Foo)
26
- subject.template(%w[baz bif]){ def bam() end }
27
- subject.const_get(:BazBif).new.should(respond_to(:bam))
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
- it 'should register methods on the specified class' do
30
- Foo.new.should(respond_to(:baz_bif))
34
+
35
+ it 'registers methods on the template class' do
36
+ target_class.new.should respond_to(:baz_bif)
31
37
  end
32
- it 'should wire those methods to the plugin_hook method of itself' do
33
- foo = Foo.new
34
- subject.should_receive(:plugin_hook).with(foo, {}, :baz, :baz_bif)
35
- foo.baz_bif
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
- it 'should allow the user to create a custom class that will also be registered' do
38
- Foo.registry[:baz_bif].should(be(subject.const_get(:BazBif)))
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
- [:BamServer, :BamClient, :PowServer, :PowClient,
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).cloud(:ec2).security_group('wap_foo')
166
- bar_group = Ironfan.realm(:wap).cluster(:bar).cloud(:ec2).security_group('wap_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('wap_bar')
169
- bar_group.group_authorized_by.should include('wap_foo')
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).cloud(:ec2).security_group('wap_baz')
174
- bif_group = Ironfan.realm(:wap).cluster(:bif).cloud(:ec2).security_group('wap_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('wap_bif')
177
- baz_group.group_authorized.should include('wap_bif')
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).cloud(:ec2).security_groups.keys.should_not include('wap_bif')
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).cloud(:ec2).security_group('wap_bam')
186
- bam_wak_group.group_authorized_by.should include('wap_bop')
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
@@ -1,48 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
- require 'ironfan'
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
- { :image_id => 'ami-29fe7640', :ssh_user => 'bam', :bootstrap_distro => "ubuntu12.04-ironfan", },
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 :bif
11
+ environment :bif
14
12
 
15
13
  cloud(:ec2) do
16
- flavor 'm1.xlarge'
17
- image_name 'ironfan-precise'
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 :blah
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
- def manifest
32
- Ironfan.cluster(:foo_bar).facets[:baz].server(0).to_machine_manifest
30
+ after(:each) do
31
+ Ironfan.clusters.clear
32
+ Ironfan.realms.clear
33
33
  end
34
34
 
35
- it 'should choose its own name as its default environment' do
36
- Ironfan.realm(:bar).environment.to_s.should == 'bar'
35
+ def manifest
36
+ Ironfan.cluster(:bar).resolve.facets[:baz].server(0).to_machine_manifest
37
37
  end
38
38
 
39
- it 'should choose the widest possible cookbook contraints to satisfy all plugins' do
40
- Ironfan::Dsl::Component.template(%w[bam pow]) do
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[jam wam]) do
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
- bam_pow
54
- jam_wam
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 'should complain when no cookbook constraints can satisfy all plugins' do
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 'should create clusters that can be referenced later' do
84
- x = self
95
+ it 'creates clusters that can be referenced later' do
96
+ test_scope = self
85
97
  Ironfan.realm :xx do
86
- cluster(:bar).should(x.be(cluster(:bar)))
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(:xy_baz).facets.to_a.should_not(be_empty)
97
- Ironfan.cluster(:xy_baz).servers.to_a.first.should_not(be_nil)
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(:foo_bar).should_not(be_nil)
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(:foo_bar).facets[:baz].server(0).should_not(be_nil)
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[foo_bar-cluster] role[foo_bar-baz-facet]]
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[:foo_bar].resolve.facets[:baz].servers.to_a.first.to_machine_manifest.flavor.should == 'm1.xlarge'
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[:foo_bar].resolve.facets[:baz].environment.should == :bif
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(:foo_bar).facets[:baz].environment.should == :bif
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
- $:.unshift File.expand_path('../../lib', __FILE__)
2
- require 'chef'
3
- require 'chef/knife'
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
- code: File.expand_path('../..', __FILE__),
13
- fixtures: [:code, 'spec', 'fixtures'],
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
- :aws_access_key_id => 'access_key',
24
- :aws_secret_access_key => 'secret',
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.chef_config = k.config
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