Sha256: 735931f279e01eb158f317b474d35ec685e16158d009325e5a5aeb041366e9e0

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

require 'puppet'

# A module just to store the mount/unmount methods.  Individual providers
# still need to add the mount commands manually.
module Puppet::Provider::Mount
  # This only works when the mount point is synced to the fstab.
  def mount
    args = []

    # In general we do not have to pass mountoptions because we always
    # flush /etc/fstab before attempting to mount. But old code suggests
    # that MacOS always needs the mount options to be explicitly passed to
    # the mount command
    if Facter.value(:kernel) == 'Darwin'
      args << "-o" << self.options if self.options and self.options != :absent
    end
    args << resource[:name]

    mountcmd(*args)
    case get(:ensure)
    when :absent; set(:ensure => :ghost)
    when :unmounted; set(:ensure => :mounted)
    end
  end

  def remount
    info "Remounting"
    if resource[:remounts] == :true
      mountcmd "-o", "remount", resource[:name]
    else
      unmount
      mount
    end
  end

  # This only works when the mount point is synced to the fstab.
  def unmount
    umount(resource[:name])

    # Update property hash for future queries (e.g. refresh is called)
    case get(:ensure)
    when :mounted; set(:ensure => :unmounted)
    when :ghost; set(:ensure => :absent)
    end
  end

  # Is the mount currently mounted?
  def mounted?
    [:mounted, :ghost].include?(get(:ensure))
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-3.4.3 lib/puppet/provider/mount.rb
puppet-3.4.2 lib/puppet/provider/mount.rb
puppet-3.4.1 lib/puppet/provider/mount.rb
puppet-3.4.0 lib/puppet/provider/mount.rb
puppet-3.4.0.rc2 lib/puppet/provider/mount.rb
puppet-3.4.0.rc1 lib/puppet/provider/mount.rb
puppet-3.3.2 lib/puppet/provider/mount.rb
puppet-3.3.1 lib/puppet/provider/mount.rb
puppet-3.3.1.rc3 lib/puppet/provider/mount.rb
puppet-3.3.1.rc2 lib/puppet/provider/mount.rb
puppet-3.3.1.rc1 lib/puppet/provider/mount.rb
puppet-3.3.0 lib/puppet/provider/mount.rb
puppet-3.3.0.rc3 lib/puppet/provider/mount.rb
puppet-3.3.0.rc2 lib/puppet/provider/mount.rb