Skip to content

Instantly share code, notes, and snippets.

@messick
Created August 8, 2012 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messick/3296967 to your computer and use it in GitHub Desktop.
Save messick/3296967 to your computer and use it in GitHub Desktop.
part of /lib/rubber/recipes/rubber/volumes.rb
namespace :rubber do
desc <<-DESC
Sets up persistent volumes in the cloud
All volumes defined in rubber.yml will be created if necessary, and attached/mounted on their associated instances
DESC
required_task :setup_volumes do
rubber_instances.filtered.each do |ic|
env = rubber_cfg.environment.bind(ic.role_names, ic.name)
created_vols = []
vol_specs = env.volumes || []
vol_specs.each do |vol_spec|
created_vols << setup_volume(ic, vol_spec)
end
created_vols.compact!
created_parts = []
partition_specs = env.local_volumes || []
partition_specs.each do |partition_spec|
created_parts << setup_partition(ic, partition_spec)
end
created_parts.compact!
zero_partitions(ic, created_parts)
created_vols += created_parts
created_vols = created_vols.compact.uniq
raid_specs = env.raid_volumes || []
raid_volume_list = raid_specs.collect {|vol| vol["source_devices"]}.join(" ")
raid_specs.each do |raid_spec|
# we want to format if we created the ec2 volumes, or if we don't have any
# ec2 volumes and are just creating raid array from ephemeral stores
format = raid_spec['source_devices'].all? {|dev| created_vols.include?(dev.gsub("xv","s"))}
setup_raid_volume(ic, raid_spec, format, raid_volume_list)
end
lvm_volume_group_specs = env.lvm_volume_groups || []
lvm_volume_group_specs.each do |lvm_volume_group_spec|
setup_lvm_group(ic, lvm_volume_group_spec)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment