Skip to content

Commit

Permalink
Merge pull request #28 from rightscale-cookbooks/ST-1_ephemeral_previ…
Browse files Browse the repository at this point in the history
…ously_formatted

St 1 ephemeral previously formatted
  • Loading branch information
douglaswth committed Apr 8, 2015
2 parents 7c4d95b + efe11ad commit 9a687fb
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
12 changes: 7 additions & 5 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
require_chef_omnibus: 11.6.0

platforms:
- name: centos-5.9
Expand All @@ -13,6 +13,9 @@ platforms:
- name: centos-7.0
driver_config:
box: opscode-centos-7.0
attributes:
ephemeral_lvm:
filesystem: xfs
- name: debian-7.2.0
driver_config:
box: opscode-debian-7.2.0
Expand All @@ -24,6 +27,9 @@ platforms:
driver_config:
box: local-rhel-7.0
box_url: file://<%= File.expand_path('~') %>/opscode_rhel-7.0_chef-provisionerless.box
attributes:
ephemeral_lvm:
filesystem: xfs
- name: ubuntu-10.04
driver_config:
box: opscode-ubuntu-10.04
Expand All @@ -45,8 +51,6 @@ suites:
attributes:
cloud:
provider: vagrant
ephemeral_lvm:
filesystem: ext3
vagrant:
block_device_mapping_ephemeral0: loop0
block_device_mapping_ephemeral1: loop1
Expand All @@ -62,8 +66,6 @@ suites:
attributes:
cloud:
provider: gce
ephemeral_lvm:
filesystem: ext3
gce:
attached_disks:
disks:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ ephemeral_lvm Cookbook CHANGELOG

This file is used to list changes made in each version of the ephemeral_lvm cookbook.

v1.0.9
------

- Run 'wipefs' on each ephemeral disk erasing any filesystem signatures, avoiding user interaction during lvm commands.

v1.0.8
------

Expand Down
4 changes: 3 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#

# The ephemeral file system
default['ephemeral_lvm']['filesystem'] = "ext4"
# RHEL 7 and CentOS 7 uses XFS as their default file system.
default['ephemeral_lvm']['filesystem'] =
node['platform_family'] == 'rhel' && node['platform_version'] =~ /^7\./ ? 'xfs' : 'ext4'

# The ephemeral mount point
default['ephemeral_lvm']['mount_point'] = "/mnt/ephemeral"
Expand Down
7 changes: 4 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Configures available ephemeral devices on a cloud server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.8'
version '1.0.9'

supports 'ubuntu'
supports 'centos'
Expand All @@ -16,8 +16,9 @@

attribute "ephemeral_lvm/filesystem",
:display_name => "Ephemeral LVM Filesystem",
:description => "The filesystem to be used on the ephemeral volume",
:default => "ext4",
:description =>
"The filesystem to be used on the ephemeral volume." +
" Defaults are based on OS and determined in attributes/defaults.rb.",
:recipes => ["ephemeral_lvm::default"],
:required => "recommended"

Expand Down
13 changes: 13 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
else
log "Ephemeral disks found for cloud '#{cloud}': #{ephemeral_devices.inspect}"

# Ephemeral disks may have been previously formatted, which can hang some lvm calls.
# Run 'wipefs' on each ephemeral disk to remove any filesystem signatures.
#
check_volume_group = Mixlib::ShellOut.new("vgs #{node['ephemeral_lvm']['volume_group_name']}").run_command
if check_volume_group.exitstatus != 0
ephemeral_devices.each do |ephemeral_device|
log "Preparing #{ephemeral_device}"
execute "wipefs --all #{ephemeral_device}"
end
else
log "No need to remove ephemeral disk filesystem signatures."
end

# Create the volume group and logical volume. If more than one ephemeral disk is found,
# they are created with LVM stripes with the stripe size set in the attributes.
#
Expand Down
17 changes: 15 additions & 2 deletions test/integration/default/bats/verify_ephemeral.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ export PATH=$PATH:/sbin:/usr/sbin
}

@test "ephemeral logical volume is mounted to /mnt/ephemeral" {
if type -P lsb_release; then
is_rhel=`lsb_release -sir | grep -Pqiz "^(centos|redHatEnterpriseServer)\s6\." && echo "true" || echo "false"`
else
# On RHEL: Red Hat Enterprise Linux Server release 7.1 (Maipo)
# On CentOS: CentOS Linux release 7.0.1406 (Core)
is_rhel=`grep -Pqiz "^(centos|red hat enterprise) linux.+ 7\." /etc/redhat-release && echo "true" || echo "false"`
fi

if [[ $is_rhel == "true" ]]; then
filesystem='xfs'
else
filesystem='ext4'
fi
mountpoint /mnt/ephemeral
mount | grep "/dev/mapper/vg--data-ephemeral0 on /mnt/ephemeral type ext3"
grep -P "/dev/mapper/vg--data-ephemeral0\s+/mnt/ephemeral\s+ext3\s+defaults,noauto\s+0\s+0" /etc/fstab
mount | egrep "^/dev/mapper/vg--data-ephemeral0 on /mnt/ephemeral type $filesystem"
egrep "/dev/mapper/vg--data-ephemeral0\s+/mnt/ephemeral\s+$filesystem\s+defaults,noauto\s+0\s+0" /etc/fstab
}
17 changes: 15 additions & 2 deletions test/integration/gce/bats/verify_ephemeral.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@ export PATH=$PATH:/sbin:/usr/sbin
}

@test "ephemeral logical volume is mounted to /mnt/ephemeral" {
if type -P lsb_release; then
is_rhel=`lsb_release -sir | grep -Pqiz "^(centos|redHatEnterpriseServer)\s6\." && echo "true" || echo "false"`
else
# On RHEL: Red Hat Enterprise Linux Server release 7.1 (Maipo)
# On CentOS: CentOS Linux release 7.0.1406 (Core)
is_rhel=`grep -Pqiz "^(centos|red hat enterprise) linux.+ 7\." /etc/redhat-release && echo "true" || echo "false"`
fi

if [[ $is_rhel == "true" ]]; then
filesystem='xfs'
else
filesystem='ext4'
fi
mountpoint /mnt/ephemeral
mount | grep "/dev/mapper/vg--data-ephemeral0 on /mnt/ephemeral type ext3"
grep -P "/dev/mapper/vg--data-ephemeral0\s+/mnt/ephemeral\s+ext3\s+defaults,noauto\s+0\s+0" /etc/fstab
mount | egrep "^/dev/mapper/vg--data-ephemeral0 on /mnt/ephemeral type $filesystem"
egrep "/dev/mapper/vg--data-ephemeral0\s+/mnt/ephemeral\s+$filesystem\s+defaults,noauto\s+0\s+0" /etc/fstab
}

0 comments on commit 9a687fb

Please sign in to comment.