ironfan 3.2.2 → 4.0.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.
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/ironfan.gemspec +33 -20
- data/lib/chef/knife/cluster_kick.rb +17 -17
- data/lib/chef/knife/cluster_kill.rb +13 -7
- data/lib/chef/knife/cluster_launch.rb +60 -66
- data/lib/chef/knife/cluster_pry.rb +2 -2
- data/lib/chef/knife/cluster_show.rb +3 -6
- data/lib/chef/knife/cluster_ssh.rb +5 -11
- data/lib/chef/knife/cluster_start.rb +2 -4
- data/lib/chef/knife/cluster_stop.rb +1 -3
- data/lib/chef/knife/cluster_sync.rb +13 -21
- data/lib/chef/knife/ironfan_knife_common.rb +11 -9
- data/lib/chef/knife/ironfan_script.rb +2 -1
- data/lib/gorillib/resolution.rb +119 -0
- data/lib/ironfan/broker/computer.rb +316 -0
- data/lib/ironfan/broker/drive.rb +21 -0
- data/lib/ironfan/broker.rb +37 -0
- data/lib/ironfan/builder.rb +14 -0
- data/lib/ironfan/deprecated.rb +16 -58
- data/lib/ironfan/dsl/cloud.rb +21 -0
- data/lib/ironfan/dsl/cluster.rb +27 -0
- data/lib/ironfan/dsl/compute.rb +84 -0
- data/lib/ironfan/dsl/ec2.rb +260 -0
- data/lib/ironfan/dsl/facet.rb +25 -0
- data/lib/ironfan/dsl/role.rb +19 -0
- data/lib/ironfan/dsl/server.rb +31 -0
- data/lib/ironfan/dsl/virtualbox.rb +8 -0
- data/lib/ironfan/dsl/volume.rb +45 -0
- data/lib/ironfan/dsl.rb +7 -0
- data/lib/ironfan/headers.rb +58 -0
- data/lib/ironfan/provider/chef/client.rb +77 -0
- data/lib/ironfan/provider/chef/node.rb +133 -0
- data/lib/ironfan/provider/chef/role.rb +69 -0
- data/lib/ironfan/provider/chef.rb +28 -0
- data/lib/ironfan/provider/ec2/ebs_volume.rb +137 -0
- data/lib/ironfan/provider/ec2/elastic_ip.rb +10 -0
- data/lib/ironfan/provider/ec2/key_pair.rb +65 -0
- data/lib/ironfan/provider/ec2/machine.rb +258 -0
- data/lib/ironfan/provider/ec2/placement_group.rb +24 -0
- data/lib/ironfan/provider/ec2/security_group.rb +118 -0
- data/lib/ironfan/provider/ec2.rb +47 -0
- data/lib/ironfan/provider/virtualbox/machine.rb +10 -0
- data/lib/ironfan/provider/virtualbox.rb +8 -0
- data/lib/ironfan/provider.rb +139 -0
- data/lib/ironfan/requirements.rb +52 -0
- data/lib/ironfan.rb +44 -33
- metadata +34 -21
- data/lib/chef/knife/cluster_vagrant.rb +0 -144
- data/lib/chef/knife/vagrant/ironfan_environment.rb +0 -18
- data/lib/chef/knife/vagrant/ironfan_provisioners.rb +0 -27
- data/lib/chef/knife/vagrant/skeleton_vagrantfile.rb +0 -119
- data/lib/ironfan/chef_layer.rb +0 -300
- data/lib/ironfan/cloud.rb +0 -323
- data/lib/ironfan/cluster.rb +0 -118
- data/lib/ironfan/compute.rb +0 -139
- data/lib/ironfan/discovery.rb +0 -190
- data/lib/ironfan/dsl_builder.rb +0 -99
- data/lib/ironfan/facet.rb +0 -143
- data/lib/ironfan/fog_layer.rb +0 -196
- data/lib/ironfan/private_key.rb +0 -130
- data/lib/ironfan/role_implications.rb +0 -58
- data/lib/ironfan/security_group.rb +0 -133
- data/lib/ironfan/server.rb +0 -291
- data/lib/ironfan/server_slice.rb +0 -265
- data/lib/ironfan/volume.rb +0 -146
@@ -0,0 +1,84 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Compute < Ironfan::Dsl
|
5
|
+
@@run_list_rank = 0
|
6
|
+
field :name, String
|
7
|
+
|
8
|
+
# Resolve each of the following as a merge of their container's attributes and theirs
|
9
|
+
collection :run_list_items, Hash, :resolver => :merge_resolve
|
10
|
+
collection :clouds, Ironfan::Dsl::Cloud, :resolver => :merge_resolve
|
11
|
+
collection :volumes, Ironfan::Dsl::Volume, :resolver => :merge_resolve
|
12
|
+
|
13
|
+
# Resolve these normally (overriding on each layer)
|
14
|
+
magic :environment, Symbol, :default => :_default
|
15
|
+
magic :use_cloud, Symbol
|
16
|
+
|
17
|
+
member :cluster_role, Ironfan::Dsl::Role
|
18
|
+
member :facet_role, Ironfan::Dsl::Role
|
19
|
+
|
20
|
+
def initialize(attrs={},&block)
|
21
|
+
self.underlay = attrs[:owner] if attrs[:owner]
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def fullname() name; end
|
26
|
+
|
27
|
+
# Add the given role/recipe to the run list. You can specify placement of
|
28
|
+
# `:first`, `:normal` (or nil) or `:last`; the final runlist is assembled
|
29
|
+
# in order by placement, and then by source position.
|
30
|
+
def role(role_name, placement=nil)
|
31
|
+
add_to_run_list("role[#{role_name}]", placement)
|
32
|
+
end
|
33
|
+
def recipe(recipe_name, placement=nil)
|
34
|
+
add_to_run_list(recipe_name, placement)
|
35
|
+
end
|
36
|
+
def run_list
|
37
|
+
mapper = run_list_items.values.map
|
38
|
+
result = mapper.each {|i| i[:name] if i[:placement]==:first }
|
39
|
+
result += mapper.each {|i| i[:name] if i[:placement]==:normal }
|
40
|
+
result += mapper.each {|i| i[:name] if i[:placement]==:last }
|
41
|
+
result.compact
|
42
|
+
end
|
43
|
+
|
44
|
+
def raid_group(rg_name, attrs={}, &block)
|
45
|
+
raid = volumes[rg_name] || Ironfan::Dsl::RaidGroup.new
|
46
|
+
raid.receive!(attrs, &block)
|
47
|
+
raid.sub_volumes.each do |sv_name|
|
48
|
+
volume(sv_name){ in_raid(rg_name) ; mountable(false) ; tags({}) }
|
49
|
+
end
|
50
|
+
volumes[rg_name] = raid
|
51
|
+
end
|
52
|
+
|
53
|
+
# TODO: Expand the logic here to include CLI parameters, probably by injecting
|
54
|
+
# the CLI as a layer in the underlay structure
|
55
|
+
def selected_cloud
|
56
|
+
raise "No clouds defined, cannot select a cloud" if clouds.length == 0
|
57
|
+
|
58
|
+
# Use the selected cloud for this server
|
59
|
+
unless use_cloud.nil?
|
60
|
+
return cloud(use_cloud) if clouds.include? use_cloud
|
61
|
+
raise "Requested a cloud (#{use_cloud}) that is not defined"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Use the cloud marked default_cloud
|
65
|
+
default = clouds.values.select{|c| c.default_cloud == true }
|
66
|
+
raise "More than one cloud (#{default.map{|c| c.name}.join(', ')}) marked default" if default.length > 1
|
67
|
+
return default[0] unless default.empty?
|
68
|
+
|
69
|
+
# Use the first cloud defined
|
70
|
+
clouds.values.first
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
def add_to_run_list(item, placement=nil)
|
76
|
+
raise "run_list placement must be one of :first, :normal, :last or nil (also means :normal)" unless [:first, :last, :own, nil].include?(placement)
|
77
|
+
placement = :normal if placement.nil?
|
78
|
+
@@run_list_rank += 1
|
79
|
+
run_list_items[item] = { :name => item, :rank => @@run_list_rank, :placement => placement }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Compute < Ironfan::Dsl
|
5
|
+
def ec2(*attrs,&block) cloud(:ec2,*attrs,&block); end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Ec2 < Cloud
|
9
|
+
magic :availability_zones, Array, :default => ['us-east-1d']
|
10
|
+
magic :backing, String, :default => 'ebs'
|
11
|
+
magic :bootstrap_distro, String
|
12
|
+
magic :chef_client_script, String
|
13
|
+
magic :default_availability_zone, String, :default => ->{availability_zones.first}
|
14
|
+
magic :flavor, String, :default => 't1.micro'
|
15
|
+
magic :image_name, String
|
16
|
+
magic :image_id, String
|
17
|
+
magic :keypair, Whatever
|
18
|
+
magic :mount_ephemerals, Hash, :default => {}
|
19
|
+
magic :monitoring, String
|
20
|
+
magic :permanent, :boolean, :default => false
|
21
|
+
magic :public_ip, String
|
22
|
+
magic :placement_group, String
|
23
|
+
magic :region, String, :default => -> do
|
24
|
+
default_availability_zone.gsub(/^(\w+-\w+-\d)[a-z]/, '\1') if default_availability_zone
|
25
|
+
end
|
26
|
+
collection :security_groups, Ironfan::Dsl::Ec2::SecurityGroup
|
27
|
+
magic :ssh_user, String, :default => 'ubuntu'
|
28
|
+
magic :ssh_identity_dir, String, :default => ->{ Chef::Config.ec2_key_dir }
|
29
|
+
magic :ssh_identity_file, String #, :default => "#{keypair}.pem"
|
30
|
+
magic :subnet, String
|
31
|
+
magic :validation_key, String, :default => ->{ IO.read(Chef::Config.validation_key) rescue '' }
|
32
|
+
magic :vpc, String
|
33
|
+
|
34
|
+
magic :provider, Ironfan::Provider, :default => Ironfan::Provider::Ec2
|
35
|
+
|
36
|
+
def ec2_image_info
|
37
|
+
keys = [region, flavor_info[:bits], backing, image_name]
|
38
|
+
Chef::Config[:ec2_image_info][ keys ] || {}
|
39
|
+
end
|
40
|
+
|
41
|
+
def image_id
|
42
|
+
result = read_attribute(:image_id) || ec2_image_info[:image_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_display(style,values={})
|
46
|
+
return values if style == :minimal
|
47
|
+
|
48
|
+
values["Flavor"] = flavor
|
49
|
+
values["AZ"] = default_availability_zone
|
50
|
+
return values if style == :default
|
51
|
+
|
52
|
+
values["Elastic IP"] = public_ip if public_ip
|
53
|
+
values
|
54
|
+
end
|
55
|
+
|
56
|
+
def flavor_info
|
57
|
+
if not Chef::Config[:ec2_flavor_info].has_key?(flavor)
|
58
|
+
ui.warn("Unknown machine image flavor '#{val}'")
|
59
|
+
list_flavors
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
Chef::Config[:ec2_flavor_info][flavor]
|
63
|
+
end
|
64
|
+
|
65
|
+
def implied_volumes
|
66
|
+
result = []
|
67
|
+
if backing == 'ebs'
|
68
|
+
result << Ironfan::Dsl::Volume.new(:name => 'root') do
|
69
|
+
device '/dev/sda1'
|
70
|
+
fstype 'ext4'
|
71
|
+
keep false
|
72
|
+
mount_point '/'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
return result unless (mount_ephemerals and (flavor_info[:ephemeral_volumes] > 0))
|
76
|
+
|
77
|
+
layout = { 0 => ['/dev/sdb','/mnt'],
|
78
|
+
1 => ['/dev/sdc','/mnt2'],
|
79
|
+
2 => ['/dev/sdd','/mnt3'],
|
80
|
+
3 => ['/dev/sde','/mnt4'] }
|
81
|
+
( 0 .. (flavor_info[:ephemeral_volumes]-1) ).each do |idx|
|
82
|
+
dev, mnt = layout[idx]
|
83
|
+
ephemeral = Ironfan::Dsl::Volume.new(:name => "ephemeral#{idx}") do
|
84
|
+
attachable 'ephemeral'
|
85
|
+
fstype 'ext3'
|
86
|
+
device dev
|
87
|
+
mount_point mnt
|
88
|
+
mount_options 'defaults,noatime'
|
89
|
+
tags({:bulk => true, :local => true, :fallback => true})
|
90
|
+
end
|
91
|
+
ephemeral.receive! mount_ephemerals
|
92
|
+
result << ephemeral
|
93
|
+
end
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
class SecurityGroup < Ironfan::Dsl
|
98
|
+
field :name, String
|
99
|
+
field :group_authorized_by, Array, :default => []
|
100
|
+
field :range_authorizations, Array, :default => []
|
101
|
+
|
102
|
+
def authorize_port_range(range, cidr_ip = '0.0.0.0/0', ip_protocol = 'tcp')
|
103
|
+
range = (range .. range) if range.is_a?(Integer)
|
104
|
+
range_authorizations << [range, cidr_ip, ip_protocol]
|
105
|
+
range_authorizations.compact!
|
106
|
+
end
|
107
|
+
|
108
|
+
def authorized_by_group(other_name)
|
109
|
+
group_authorized_by << other_name.to_s
|
110
|
+
group_authorized_by.compact!
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
Chef::Config[:ec2_flavor_info] ||= {}
|
120
|
+
Chef::Config[:ec2_flavor_info].merge!({
|
121
|
+
't1.micro' => { :price => 0.02, :bits => '64-bit', :ram => 686, :cores => 1, :core_size => 0.25, :inst_disks => 0, :inst_disk_size => 0, :ephemeral_volumes => 0 },
|
122
|
+
'm1.small' => { :price => 0.08, :bits => '64-bit', :ram => 1740, :cores => 1, :core_size => 1, :inst_disks => 1, :inst_disk_size => 160, :ephemeral_volumes => 1 },
|
123
|
+
'm1.medium' => { :price => 0.165, :bits => '32-bit', :ram => 3840, :cores => 2, :core_size => 1, :inst_disks => 1, :inst_disk_size => 410, :ephemeral_volumes => 1 },
|
124
|
+
'c1.medium' => { :price => 0.17, :bits => '32-bit', :ram => 1740, :cores => 2, :core_size => 2.5, :inst_disks => 1, :inst_disk_size => 350, :ephemeral_volumes => 1 },
|
125
|
+
'm1.large' => { :price => 0.32, :bits => '64-bit', :ram => 7680, :cores => 2, :core_size => 2, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 },
|
126
|
+
'm2.xlarge' => { :price => 0.45, :bits => '64-bit', :ram => 18124, :cores => 2, :core_size => 3.25, :inst_disks => 1, :inst_disk_size => 420, :ephemeral_volumes => 1 },
|
127
|
+
'c1.xlarge' => { :price => 0.64, :bits => '64-bit', :ram => 7168, :cores => 8, :core_size => 2.5, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 },
|
128
|
+
'm1.xlarge' => { :price => 0.66, :bits => '64-bit', :ram => 15360, :cores => 4, :core_size => 2, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 },
|
129
|
+
'm2.2xlarge' => { :price => 0.90, :bits => '64-bit', :ram => 35020, :cores => 4, :core_size => 3.25, :inst_disks => 2, :inst_disk_size => 850, :ephemeral_volumes => 2 },
|
130
|
+
'm2.4xlarge' => { :price => 1.80, :bits => '64-bit', :ram => 70041, :cores => 8, :core_size => 3.25, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 4 },
|
131
|
+
'cc1.4xlarge' => { :price => 1.30, :bits => '64-bit', :ram => 23552, :cores => 8, :core_size => 4.19, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' },
|
132
|
+
'cc1.8xlarge' => { :price => 2.40, :bits => '64-bit', :ram => 61952, :cores =>16, :core_size => 5.50, :inst_disks => 8, :inst_disk_size => 3370, :ephemeral_volumes => 4, :placement_groupable => true, :virtualization => 'hvm' },
|
133
|
+
'cg1.4xlarge' => { :price => 2.10, :bits => '64-bit', :ram => 22528, :cores => 8, :core_size => 4.19, :inst_disks => 4, :inst_disk_size => 1690, :ephemeral_volumes => 2, :placement_groupable => true, :virtualization => 'hvm' },
|
134
|
+
})
|
135
|
+
|
136
|
+
Chef::Config[:ec2_image_info] ||= {}
|
137
|
+
Chef::Config[:ec2_image_info].merge!({
|
138
|
+
#
|
139
|
+
# Lucid (Ubuntu 9.10)
|
140
|
+
#
|
141
|
+
%w[us-east-1 64-bit instance karmic ] => { :image_id => 'ami-55739e3c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
142
|
+
%w[us-east-1 32-bit instance karmic ] => { :image_id => 'ami-bb709dd2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
143
|
+
%w[us-west-1 64-bit instance karmic ] => { :image_id => 'ami-cb2e7f8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
144
|
+
%w[us-west-1 32-bit instance karmic ] => { :image_id => 'ami-c32e7f86', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
145
|
+
%w[eu-west-1 64-bit instance karmic ] => { :image_id => 'ami-05c2e971', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
146
|
+
%w[eu-west-1 32-bit instance karmic ] => { :image_id => 'ami-2fc2e95b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
147
|
+
|
148
|
+
#
|
149
|
+
# Lucid (Ubuntu 10.04.3)
|
150
|
+
#
|
151
|
+
%w[ap-southeast-1 64-bit ebs lucid ] => { :image_id => 'ami-77f28d25', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
152
|
+
%w[ap-southeast-1 32-bit ebs lucid ] => { :image_id => 'ami-4df28d1f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
153
|
+
%w[ap-southeast-1 64-bit instance lucid ] => { :image_id => 'ami-57f28d05', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
154
|
+
%w[ap-southeast-1 32-bit instance lucid ] => { :image_id => 'ami-a5f38cf7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
155
|
+
%w[eu-west-1 64-bit ebs lucid ] => { :image_id => 'ami-ab4d67df', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
156
|
+
%w[eu-west-1 32-bit ebs lucid ] => { :image_id => 'ami-a94d67dd', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
157
|
+
%w[eu-west-1 64-bit instance lucid ] => { :image_id => 'ami-a54d67d1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
158
|
+
%w[eu-west-1 32-bit instance lucid ] => { :image_id => 'ami-cf4d67bb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
159
|
+
#
|
160
|
+
%w[us-east-1 64-bit ebs lucid ] => { :image_id => 'ami-4b4ba522', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
161
|
+
%w[us-east-1 32-bit ebs lucid ] => { :image_id => 'ami-714ba518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
162
|
+
%w[us-east-1 64-bit instance lucid ] => { :image_id => 'ami-fd4aa494', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
163
|
+
%w[us-east-1 32-bit instance lucid ] => { :image_id => 'ami-2d4aa444', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
164
|
+
#
|
165
|
+
%w[us-west-1 64-bit ebs lucid ] => { :image_id => 'ami-d197c694', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
166
|
+
%w[us-west-1 32-bit ebs lucid ] => { :image_id => 'ami-cb97c68e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
167
|
+
%w[us-west-1 64-bit instance lucid ] => { :image_id => 'ami-c997c68c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
168
|
+
%w[us-west-1 32-bit instance lucid ] => { :image_id => 'ami-c597c680', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
169
|
+
|
170
|
+
#
|
171
|
+
# Maverick (Ubuntu 10.10)
|
172
|
+
#
|
173
|
+
%w[ ap-southeast-1 64-bit ebs maverick ] => { :image_id => 'ami-32423c60', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
174
|
+
%w[ ap-southeast-1 64-bit instance maverick ] => { :image_id => 'ami-12423c40', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
175
|
+
%w[ ap-southeast-1 32-bit ebs maverick ] => { :image_id => 'ami-0c423c5e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
176
|
+
%w[ ap-southeast-1 32-bit instance maverick ] => { :image_id => 'ami-7c423c2e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
177
|
+
#
|
178
|
+
%w[ eu-west-1 64-bit ebs maverick ] => { :image_id => 'ami-e59ca991', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
179
|
+
%w[ eu-west-1 64-bit instance maverick ] => { :image_id => 'ami-1b9ca96f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
180
|
+
%w[ eu-west-1 32-bit ebs maverick ] => { :image_id => 'ami-fb9ca98f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
181
|
+
%w[ eu-west-1 32-bit instance maverick ] => { :image_id => 'ami-339ca947', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
182
|
+
#
|
183
|
+
%w[ us-east-1 64-bit ebs maverick ] => { :image_id => 'ami-cef405a7', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
184
|
+
%w[ us-east-1 64-bit instance maverick ] => { :image_id => 'ami-08f40561', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
185
|
+
%w[ us-east-1 32-bit ebs maverick ] => { :image_id => 'ami-ccf405a5', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
186
|
+
%w[ us-east-1 32-bit instance maverick ] => { :image_id => 'ami-a6f504cf', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
187
|
+
#
|
188
|
+
%w[ us-west-1 64-bit ebs maverick ] => { :image_id => 'ami-af7e2eea', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
189
|
+
%w[ us-west-1 64-bit instance maverick ] => { :image_id => 'ami-a17e2ee4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
190
|
+
%w[ us-west-1 32-bit ebs maverick ] => { :image_id => 'ami-ad7e2ee8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
191
|
+
%w[ us-west-1 32-bit instance maverick ] => { :image_id => 'ami-957e2ed0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
192
|
+
|
193
|
+
#
|
194
|
+
# Natty (Ubuntu 11.04)
|
195
|
+
#
|
196
|
+
%w[ ap-northeast-1 32-bit ebs natty ] => { :image_id => 'ami-00b10501', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
197
|
+
%w[ ap-northeast-1 32-bit instance natty ] => { :image_id => 'ami-f0b004f1', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
198
|
+
%w[ ap-northeast-1 64-bit ebs natty ] => { :image_id => 'ami-02b10503', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
199
|
+
%w[ ap-northeast-1 64-bit instance natty ] => { :image_id => 'ami-fab004fb', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
200
|
+
#
|
201
|
+
%w[ ap-southeast-1 32-bit ebs natty ] => { :image_id => 'ami-06255f54', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
202
|
+
%w[ ap-southeast-1 32-bit instance natty ] => { :image_id => 'ami-72255f20', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
203
|
+
%w[ ap-southeast-1 64-bit ebs natty ] => { :image_id => 'ami-04255f56', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
204
|
+
%w[ ap-southeast-1 64-bit instance natty ] => { :image_id => 'ami-7a255f28', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
205
|
+
#
|
206
|
+
%w[ eu-west-1 32-bit ebs natty ] => { :image_id => 'ami-a4f7c5d0', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
207
|
+
%w[ eu-west-1 32-bit instance natty ] => { :image_id => 'ami-fef7c58a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
208
|
+
%w[ eu-west-1 64-bit ebs natty ] => { :image_id => 'ami-a6f7c5d2', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
209
|
+
%w[ eu-west-1 64-bit instance natty ] => { :image_id => 'ami-c0f7c5b4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
210
|
+
#
|
211
|
+
%w[ us-east-1 32-bit ebs natty ] => { :image_id => 'ami-e358958a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
212
|
+
%w[ us-east-1 32-bit instance natty ] => { :image_id => 'ami-c15994a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
213
|
+
%w[ us-east-1 64-bit ebs natty ] => { :image_id => 'ami-fd589594', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
214
|
+
%w[ us-east-1 64-bit instance natty ] => { :image_id => 'ami-71589518', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
215
|
+
#
|
216
|
+
%w[ us-west-1 32-bit ebs natty ] => { :image_id => 'ami-43580406', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
217
|
+
%w[ us-west-1 32-bit instance natty ] => { :image_id => 'ami-e95f03ac', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
218
|
+
%w[ us-west-1 64-bit ebs natty ] => { :image_id => 'ami-4d580408', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
219
|
+
%w[ us-west-1 64-bit instance natty ] => { :image_id => 'ami-a15f03e4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
220
|
+
|
221
|
+
#
|
222
|
+
# Cluster Compute
|
223
|
+
#
|
224
|
+
# IMAGE ami-6d2ce204 205199409180/Globus Provision 0.4.AMI (Ubuntu 11.04 HVM) 205199409180 available public x86_64 machine ebs hvm xen
|
225
|
+
#
|
226
|
+
%w[ us-east-1 64-bit ebs natty-cc ] => { :image_id => 'ami-6d2ce204', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
227
|
+
|
228
|
+
#
|
229
|
+
# Oneiric (Ubuntu 11.10)
|
230
|
+
#
|
231
|
+
%w[ ap-northeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-84902785', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
232
|
+
%w[ ap-northeast-1 32-bit instance oneiric ] => { :image_id => 'ami-5e90275f', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
233
|
+
%w[ ap-northeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-88902789', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
234
|
+
%w[ ap-northeast-1 64-bit instance oneiric ] => { :image_id => 'ami-7c90277d', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
235
|
+
#
|
236
|
+
%w[ ap-southeast-1 32-bit ebs oneiric ] => { :image_id => 'ami-0a327758', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
237
|
+
%w[ ap-southeast-1 32-bit instance oneiric ] => { :image_id => 'ami-00327752', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
238
|
+
%w[ ap-southeast-1 64-bit ebs oneiric ] => { :image_id => 'ami-0832775a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
239
|
+
%w[ ap-southeast-1 64-bit instance oneiric ] => { :image_id => 'ami-04327756', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
240
|
+
#
|
241
|
+
%w[ eu-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-11f0cc65', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
242
|
+
%w[ eu-west-1 32-bit instance oneiric ] => { :image_id => 'ami-4ff0cc3b', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
243
|
+
%w[ eu-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-1df0cc69', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
244
|
+
%w[ eu-west-1 64-bit instance oneiric ] => { :image_id => 'ami-23f0cc57', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
245
|
+
#
|
246
|
+
%w[ us-east-1 32-bit ebs oneiric ] => { :image_id => 'ami-a562a9cc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
247
|
+
%w[ us-east-1 32-bit instance oneiric ] => { :image_id => 'ami-3962a950', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
248
|
+
%w[ us-east-1 64-bit ebs oneiric ] => { :image_id => 'ami-bf62a9d6', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
249
|
+
%w[ us-east-1 64-bit instance oneiric ] => { :image_id => 'ami-c162a9a8', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
250
|
+
#
|
251
|
+
%w[ us-west-1 32-bit ebs oneiric ] => { :image_id => 'ami-c9a1fe8c', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
252
|
+
%w[ us-west-1 32-bit instance oneiric ] => { :image_id => 'ami-21a1fe64', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
253
|
+
%w[ us-west-1 64-bit ebs oneiric ] => { :image_id => 'ami-cba1fe8e', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
254
|
+
%w[ us-west-1 64-bit instance oneiric ] => { :image_id => 'ami-3fa1fe7a', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
255
|
+
#
|
256
|
+
%w[ us-west-2 32-bit ebs oneiric ] => { :image_id => 'ami-ea9a17da', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
257
|
+
%w[ us-west-2 32-bit instance oneiric ] => { :image_id => 'ami-f49a17c4', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
258
|
+
%w[ us-west-2 64-bit ebs oneiric ] => { :image_id => 'ami-ec9a17dc', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
259
|
+
%w[ us-west-2 64-bit instance oneiric ] => { :image_id => 'ami-fe9a17ce', :ssh_user => 'ubuntu', :bootstrap_distro => "ubuntu10.04-gems", },
|
260
|
+
})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Facet < Ironfan::Dsl::Compute
|
5
|
+
magic :instances, Integer, :default => 1
|
6
|
+
collection :servers, Ironfan::Dsl::Server, :resolver => :deep_resolve
|
7
|
+
field :cluster_name, String
|
8
|
+
|
9
|
+
def initialize(attrs={},&block)
|
10
|
+
self.cluster_name = attrs[:owner].name unless attrs[:owner].nil?
|
11
|
+
self.name = attrs[:name] unless attrs[:name].nil?
|
12
|
+
self.facet_role Ironfan::Dsl::Role.new(:name => fullname.sub('-','_'))
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def fullname() "#{cluster_name}-#{name}"; end
|
17
|
+
|
18
|
+
def expand_servers!
|
19
|
+
for i in 0..(instances-1) do server(i); end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Role < Ironfan::Dsl
|
5
|
+
magic :override_attributes, Hash, :default => {}
|
6
|
+
magic :default_attributes, Hash, :default => {}
|
7
|
+
|
8
|
+
def override_attributes(val=nil)
|
9
|
+
return super() if val.nil?
|
10
|
+
super(read_attribute(:override_attributes).deep_merge(val))
|
11
|
+
end
|
12
|
+
def default_attributes(val=nil)
|
13
|
+
return super() if val.nil?
|
14
|
+
super(read_attribute(:default_attributes).deep_merge(val))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Server < Ironfan::Dsl::Compute
|
5
|
+
field :cluster_name, String
|
6
|
+
field :facet_name, String
|
7
|
+
|
8
|
+
def initialize(attrs={},&block)
|
9
|
+
unless attrs[:owner].nil?
|
10
|
+
self.cluster_name = attrs[:owner].cluster_name
|
11
|
+
self.facet_name = attrs[:owner].name
|
12
|
+
end
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def fullname() "#{cluster_name}-#{facet_name}-#{name}"; end
|
17
|
+
def index() name.to_i; end
|
18
|
+
def implied_volumes() selected_cloud.implied_volumes; end
|
19
|
+
|
20
|
+
def to_display(style,values={})
|
21
|
+
selected_cloud.to_display(style,values)
|
22
|
+
|
23
|
+
return values if style == :minimal
|
24
|
+
|
25
|
+
values["Env"] = environment
|
26
|
+
values
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Dsl
|
3
|
+
|
4
|
+
class Volume < Ironfan::Dsl
|
5
|
+
field :name, String
|
6
|
+
|
7
|
+
magic :attachable, String, :default => 'ebs'
|
8
|
+
magic :availability_zone, String
|
9
|
+
magic :create_at_launch, :boolean, :default => false
|
10
|
+
magic :device, String
|
11
|
+
magic :formattable, :boolean, :default => false
|
12
|
+
magic :fstype, String, :default => 'xfs'
|
13
|
+
magic :in_raid, :boolean, :default => false
|
14
|
+
magic :keep, :boolean, :default => true
|
15
|
+
magic :mount_dump, String
|
16
|
+
magic :mount_pass, String
|
17
|
+
magic :mount_options, String, :default => 'defaults,nouuid,noatime'
|
18
|
+
magic :mount_point, String
|
19
|
+
magic :mountable, :boolean, :default => true
|
20
|
+
magic :size, String
|
21
|
+
magic :volume_id, String
|
22
|
+
magic :resizable, :boolean, :default => false
|
23
|
+
magic :snapshot_id, String
|
24
|
+
magic :snapshot_name, String
|
25
|
+
magic :tags, Hash, :default => {}
|
26
|
+
end
|
27
|
+
|
28
|
+
class RaidGroup < Volume
|
29
|
+
# volumes that comprise this raid group
|
30
|
+
magic :sub_volumes, Array, :default => []
|
31
|
+
# RAID level (http://en.wikipedia.org/wiki/RAID#Standard_levels)
|
32
|
+
magic :level, String
|
33
|
+
# Raid chunk size (https://raid.wiki.kernel.org/articles/r/a/i/RAID_setup_cbb2.html)
|
34
|
+
magic :chunk, String
|
35
|
+
# read-ahead buffer
|
36
|
+
magic :read_ahead, String
|
37
|
+
|
38
|
+
# Overrides of Volume field defaults
|
39
|
+
magic :attachable, :boolean, :default => false
|
40
|
+
magic :formattable, :boolean, :default => true
|
41
|
+
magic :mount_options, String, :default => 'defaults,nobootwait,noatime,nouuid,comment=ironfan'
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
data/lib/ironfan/dsl.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file sets up the base class structure before any of it is
|
2
|
+
# loaded, to allow parts to declare relationships to each other
|
3
|
+
# without regard to declaration order. No active code should
|
4
|
+
# be present in this file.
|
5
|
+
module Ironfan
|
6
|
+
|
7
|
+
class Builder
|
8
|
+
include Gorillib::Builder
|
9
|
+
end
|
10
|
+
|
11
|
+
class Broker < Builder
|
12
|
+
class Computer < Builder; end
|
13
|
+
class Computers < Gorillib::ModelCollection; end
|
14
|
+
class Drive < Builder; end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Dsl < Builder
|
18
|
+
class Compute < Ironfan::Dsl; end
|
19
|
+
class Cluster < Ironfan::Dsl::Compute; end
|
20
|
+
class Facet < Ironfan::Dsl::Compute; end
|
21
|
+
class Server < Ironfan::Dsl::Compute; end
|
22
|
+
|
23
|
+
class Role < Ironfan::Dsl; end
|
24
|
+
class Volume < Ironfan::Dsl; end
|
25
|
+
|
26
|
+
class Cloud < Ironfan::Dsl; end
|
27
|
+
class Ec2 < Cloud
|
28
|
+
class SecurityGroup < Ironfan::Dsl; end
|
29
|
+
end
|
30
|
+
class VirtualBox < Cloud; end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Provider < Builder
|
34
|
+
class Resource < Builder; end
|
35
|
+
end
|
36
|
+
class IaasProvider < Provider
|
37
|
+
class Machine < Resource; end
|
38
|
+
end
|
39
|
+
class Provider
|
40
|
+
class ChefServer < Ironfan::Provider
|
41
|
+
class Client < Ironfan::Provider::Resource; end
|
42
|
+
class Node < Ironfan::Provider::Resource; end
|
43
|
+
class Role < Ironfan::Provider::Resource; end
|
44
|
+
end
|
45
|
+
class Ec2 < Ironfan::IaasProvider
|
46
|
+
class EbsVolume < Ironfan::Provider::Resource; end
|
47
|
+
class ElasticIp < Ironfan::Provider::Resource; end
|
48
|
+
class Machine < Ironfan::IaasProvider::Machine; end
|
49
|
+
class KeyPair < Ironfan::Provider::Resource; end
|
50
|
+
class PlacementGroup < Ironfan::Provider::Resource; end
|
51
|
+
class SecurityGroup < Ironfan::Provider::Resource; end
|
52
|
+
end
|
53
|
+
class VirtualBox < Ironfan::IaasProvider
|
54
|
+
class Machine < Ironfan::IaasProvider::Machine; end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Ironfan
|
2
|
+
class Provider
|
3
|
+
class ChefServer
|
4
|
+
|
5
|
+
class Client < Ironfan::Provider::Resource
|
6
|
+
delegate :add_to_index, :admin, :cdb_destroy, :cdb_save,
|
7
|
+
:class_from_file, :couchdb, :couchdb=, :couchdb_id, :couchdb_id=,
|
8
|
+
:couchdb_rev, :couchdb_rev=, :create, :create_keys,
|
9
|
+
:delete_from_index, :destroy, :from_file, :index_id, :index_id=,
|
10
|
+
:index_object_type, :name, :public_key, :save, :set_or_return,
|
11
|
+
:to_hash, :validate, :with_indexer_metadata,
|
12
|
+
:to => :adaptee
|
13
|
+
field :key_filename, String,
|
14
|
+
:default => ->{ "#{Client.key_dir}/client-#{name}.pem" }
|
15
|
+
|
16
|
+
def initialize(*args)
|
17
|
+
super
|
18
|
+
self.adaptee ||= Chef::ApiClient.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.shared?() false; end
|
22
|
+
def self.multiple?() false; end
|
23
|
+
def self.resource_type() :client; end
|
24
|
+
def self.expected_ids(computer) [computer.server.fullname]; end
|
25
|
+
|
26
|
+
def self.key_dir
|
27
|
+
Chef::Config.client_key_dir || "/tmp/#{ENV['USER']}-client_keys"
|
28
|
+
end
|
29
|
+
|
30
|
+
def private_key(body=nil)
|
31
|
+
if body.nil?
|
32
|
+
body = File.open(key_filename, "rb").read
|
33
|
+
else
|
34
|
+
File.open(key_filename, "w", 0600){|f| f.print( body ) }
|
35
|
+
end
|
36
|
+
adaptee.private_key(body)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Discovery
|
41
|
+
#
|
42
|
+
def self.load!(cluster=nil)
|
43
|
+
nameq = "name:#{cluster.name}-* OR clientname:#{cluster.name}-*"
|
44
|
+
ChefServer.search(:client, nameq) do |client|
|
45
|
+
register client unless client.blank?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Manipulation
|
51
|
+
#
|
52
|
+
def self.create!(computer)
|
53
|
+
return if computer.client?
|
54
|
+
client = Client.new
|
55
|
+
client.name computer.server.fullname
|
56
|
+
client.admin false
|
57
|
+
|
58
|
+
params = {:name => client.name, :admin => client.admin, :private_key => true }
|
59
|
+
result = ChefServer.post_rest("clients", params)
|
60
|
+
client.private_key(result["private_key"])
|
61
|
+
|
62
|
+
computer[:client] = client
|
63
|
+
remember client
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.destroy!(computer)
|
67
|
+
return unless computer.client?
|
68
|
+
forget computer.client.name
|
69
|
+
computer.client.destroy
|
70
|
+
File.delete(computer.client.key_filename)
|
71
|
+
computer.delete(:client)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|