[chef] Re: Re: How to format a volume and mount after using aws_ebs_volume


Chronological Thread 
  • From: David Montgomery < >
  • To:
  • Subject: [chef] Re: Re: How to format a volume and mount after using aws_ebs_volume
  • Date: Sun, 23 Jun 2013 12:09:04 +0800

Hi is what I used...seemed to work but I am not too happy about the execute blocks.  Any way to make more pretty?



include_recipe "aws"
data_bag("my_data_bag")
db = data_bag_item("my_data_bag", "my")
aws = db['development']['aws']

aws_ebs_volume "db_ebs_volume" do
  aws_access_key aws['aws_access_key_id']
  aws_secret_access_key aws['aws_secret_access_key']
  size 50
  device "/dev/sdi"
  action [ :create, :attach ]
end

execute "format_vol" do
  command "sudo mkfs.ext3 /dev/xvdi"
  action :run
  not_if {File.exists?("/data")}
end
execute "mkdir_data" do
  command "sudo mkdir /data"
  action :run
  not_if {File.exists?("/data")}
end

mount "/data" do
  device "/dev/xvdi"
  fstype "ext3"
  action [:mount, :enable]
end


On Sun, Jun 23, 2013 at 9:57 AM, Julian C. Dunn < " target="_blank"> > wrote:
On Sat, Jun 22, 2013 at 12:24 AM, David Montgomery < " target="_blank"> > wrote:
Hi,
I used the below to attach a volume to an ec2 isntances.


aws_ebs_volume "db_ebs_volume" do
  aws_access_key aws['aws_access_key_id']
  aws_secret_access_key aws['aws_secret_access_key']
  size 50
  device "/dev/sdi"
  action [ :create, :attach ]
end

I need to now format the volume
create a directory called /data
then mount the the volume with the /data directory.

What is the best chefonic method to achive this is a recipe?

I have tried this before, and I called out to shell to do invoke mkfs. Problem arises when you want ext3/ext4 -- the ext3utils don't give you a way to test whether a volume is formatted before you reformat it :-/ mkfs.xfs will, however, return a non-zero exit code that you can use.

For mounting, you can use the built-in mount resource.

http://docs.opscode.com/resource_mount.html
 
- Julian

--
[ Julian C. Dunn < " target="_blank"> >          * Sorry, I'm    ]
[ WWW: http://www.aquezada.com/staff/julian    * only Web 1.0  ]
[ gopher://sdf.org/1/users/keymaker/           * compliant!    ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9       ]




Archive powered by MHonArc 2.6.16.

§