class Chef::Provider::Mount
Attributes
Public Class Methods
Chef::Provider::new
# File lib/chef/provider/mount.rb, line 33 def initialize(new_resource, run_context) super self.unmount_retries = 20 end
Public Instance Methods
It’s entirely plausible that a site might prefer UUIDs or labels, so we need to be able to update fstab to conform with their wishes without necessarily needing to remount the device. See #6851 for more. We have to compare current resource device with device_fstab
value because entry in /etc/fstab will be as per device_type. For Ex: ‘LABEL=/tmp/ /mnt ext3 defaults 0 2’, where ‘device_type’ is :label.
# File lib/chef/provider/mount.rb, line 128 def device_unchanged? @current_resource.device == device_fstab end
should implement disabling of the filesystem (e.g. in /etc/fstab), raises if action does not succeed
# File lib/chef/provider/mount.rb, line 160 def disable_fs raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :disable" end
should implement enabling of the filesystem (e.g. in /etc/fstab), raises if action does not succeed
# File lib/chef/provider/mount.rb, line 155 def enable_fs raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :enable" end
# File lib/chef/provider/mount.rb, line 29 def load_current_resource true end
should implement mounting of the filesystem, raises if action does not succeed
# File lib/chef/provider/mount.rb, line 139 def mount_fs raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :mount" end
should check new_resource against current_resource to see if mount options need updating, returns true/false
# File lib/chef/provider/mount.rb, line 117 def mount_options_unchanged? raise Chef::Exceptions::UnsupportedAction, "#{self} does not implement #mount_options_unchanged?" end
should actually check if the filesystem is mounted (not just return current_resource) and return true/false
# File lib/chef/provider/mount.rb, line 112 def mounted? raise Chef::Exceptions::UnsupportedAction, "#{self} does not implement #mounted?" end
should implement remounting of the filesystem (via a -o remount or some other atomic-ish action that isn’t simply a umount/mount style remount), raises if action does not succeed
# File lib/chef/provider/mount.rb, line 150 def remount_fs raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :remount" end
should implement unmounting of the filesystem, raises if action does not succeed
# File lib/chef/provider/mount.rb, line 144 def umount_fs raise Chef::Exceptions::UnsupportedAction, "#{self} does not support :umount" end
Private Instance Methods
Returns the new_resource device as per device_type
# File lib/chef/provider/mount.rb, line 177 def device_fstab # Removed "/" from the end of str unless it's a network mount, because it was causing idempotency issue. device = if @new_resource.device == "/" || @new_resource.device.match?(":/$") @new_resource.device else @new_resource.device.chomp("/") end case @new_resource.device_type when :device device when :label "LABEL=#{device}" when :uuid "UUID=#{device}" end end
# File lib/chef/provider/mount.rb, line 166 def wait_until_unmounted(tries) while mounted? if (tries -= 1) < 0 raise Chef::Exceptions::Mount, "Retries exceeded waiting for filesystem to unmount" end sleep 0.1 end end