Module: Puppet::Provider::Mount

Defined in:
lib/puppet/provider/mount.rb

Overview

A module just to store the mount/unmount methods. Individual providers still need to add the mount commands manually.

Instance Method Summary collapse

Instance Method Details

#mountObject

This only works when the mount point is synced to the fstab.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppet/provider/mount.rb', line 7

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

#mounted?Boolean

Is the mount currently mounted?

Returns:

  • (Boolean)


56
57
58
# File 'lib/puppet/provider/mount.rb', line 56

def mounted?
  [:mounted, :ghost].include?(get(:ensure))
end

#remountObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet/provider/mount.rb', line 26

def remount
  #TRANSLATORS refers to remounting a file system
  info _("Remounting")
  if resource[:remounts] == :true
    mountcmd "-o", "remount", resource[:name]
  elsif ["FreeBSD", "DragonFly", "OpenBSD"].include?(Facter.value(:operatingsystem))
    if self.options && !self.options.empty?
      options = self.options + ",update"
    else
      options = "update"
    end
    mountcmd "-o", options, resource[:name]
  else
    unmount
    mount
  end
end

#unmountObject

This only works when the mount point is synced to the fstab.



45
46
47
48
49
50
51
52
53
# File 'lib/puppet/provider/mount.rb', line 45

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