Well, the second execute could be a directory resource. For detecting if the volume is formatted, you can use blkid. That’s what the lvm_logical_volume provider in the lvm cookbook does. Or, if you’re willing to use LVM, just use the lvm cookbook to do it:
lvm_volume_group ‘vg-data’ do
physical_volumes '/dev/sdi’
logical_volume ‘data’ do
size '100%VG’
filesystem 'ext3’
mount_point '/data’
end
end
Greg Symons
Sent from my IPad
On Jun 22, 2013, at 11:10 PM, “David Montgomery” <davidmontgomery@gmail.commailto:davidmontgomery@gmail.com> wrote:
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 <jdunn@aquezada.commailto:jdunn@aquezada.com> wrote:
On Sat, Jun 22, 2013 at 12:24 AM, David Montgomery <davidmontgomery@gmail.commailto:davidmontgomery@gmail.com> 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 C. Dunn <jdunn@aquezada.commailto:jdunn@aquezada.com> * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/http://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]