class Chef::Provider::Mount

Attributes

unmount_retries[RW]

Public Class Methods

new(new_resource, run_context) click to toggle source
Calls superclass method 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

device_unchanged?() click to toggle source

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
disable_fs() click to toggle source

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
enable_fs() click to toggle source

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
load_current_resource() click to toggle source
# File lib/chef/provider/mount.rb, line 29
def load_current_resource
  true
end
mount_fs() click to toggle source

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
mount_options_unchanged?() click to toggle source

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
mounted?() click to toggle source

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
remount_fs() click to toggle source

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
umount_fs() click to toggle source

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

device_fstab() click to toggle source

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
wait_until_unmounted(tries) click to toggle source
# 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