diff --git a/.kitchen.yml b/.kitchen.yml index 95d1e28..3b04fd4 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,7 +1,7 @@ --- driver_plugin: vagrant driver_config: - require_chef_omnibus: true + require_chef_omnibus: 11.6.0 platforms: - name: centos-5.9 @@ -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 @@ -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 @@ -45,8 +51,6 @@ suites: attributes: cloud: provider: vagrant - ephemeral_lvm: - filesystem: ext3 vagrant: block_device_mapping_ephemeral0: loop0 block_device_mapping_ephemeral1: loop1 @@ -62,8 +66,6 @@ suites: attributes: cloud: provider: gce - ephemeral_lvm: - filesystem: ext3 gce: attached_disks: disks: diff --git a/CHANGELOG.md b/CHANGELOG.md index f3030b0..16f17c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ------ diff --git a/attributes/default.rb b/attributes/default.rb index 979d322..5021410 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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" diff --git a/metadata.rb b/metadata.rb index 215c1ca..a819c69 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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' @@ -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" diff --git a/recipes/default.rb b/recipes/default.rb index 2313ae4..05c942e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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. # diff --git a/test/integration/default/bats/verify_ephemeral.bats b/test/integration/default/bats/verify_ephemeral.bats index 56b4d0f..56ffa73 100644 --- a/test/integration/default/bats/verify_ephemeral.bats +++ b/test/integration/default/bats/verify_ephemeral.bats @@ -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 } diff --git a/test/integration/gce/bats/verify_ephemeral.bats b/test/integration/gce/bats/verify_ephemeral.bats index 11c6355..1b1937e 100644 --- a/test/integration/gce/bats/verify_ephemeral.bats +++ b/test/integration/gce/bats/verify_ephemeral.bats @@ -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 }