Created
March 11, 2013 21:05
-
-
Save miah/5137749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # something that allocates X volumes of Y size and stripes | |
| # them into a single volume, and mounts/fstab's that volume | |
| # | |
| action :create do | |
| aws = data_bag_item('credentials', 'aws') | |
| ebs_devices = [] | |
| lvm_devices = [] | |
| block = 'f' | |
| if ::File.blockdev?('/dev/xvda1') | |
| block_dev = '/dev/xvd' | |
| else | |
| block_dev = '/dev/sd' | |
| end | |
| new_resource.volumes.times do | |
| ebs_devices << block.dup | |
| lvm_devices << "#{ block_dev }#{ block }" | |
| block.next! | |
| end | |
| ebs_devices.each do |vol| | |
| ebs_res_name = "ebs_#{ vol }" | |
| aws_ebs_volume ebs_res_name do | |
| size new_resource.size | |
| device "/dev/sd#{ vol }" | |
| aws_secret_access_key aws['ebs']['secret_access_key'] | |
| aws_access_key aws['ebs']['access_key_id'] | |
| action [:create, :attach] | |
| end | |
| end | |
| sanitized_name = new_resource.mount_point.gsub('/', '_') | |
| mp = { 'location' => new_resource.mount_point } | |
| fs = new_resource.filesystem | |
| vols = new_resource.volumes | |
| lvm_volume_group "vg#{ sanitized_name }" do | |
| physical_volumes lvm_devices | |
| logical_volume "lv#{ sanitized_name }" do | |
| size '100%VG' | |
| mount_point mp | |
| stripes vols | |
| filesystem fs | |
| end | |
| end | |
| new_resource.updated_by_last_action(true) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment