summaryrefslogtreecommitdiff
path: root/lib/chef/resource/mount.rb
blob: dffb96cb531cca62910a66217114055acd98868f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
# Copyright:: Copyright 2009-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "chef/resource"

class Chef
  class Resource
    class Mount < Chef::Resource
      description "Use the mount resource to manage a mounted file system."

      default_action :mount
      allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable

      # this is a poor API please do not re-use this pattern
      property :supports, Hash,
        default: lazy { { remount: false } },
        coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x }

      property :password, String, sensitive: true

      property :mount_point, String, name_property: true
      property :device, String, identity: true

      property :device_type, [String, Symbol],
        coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
        default: :device,
        equal_to: RUBY_PLATFORM =~ /solaris/i ? %i{ device } : %i{ device label uuid }

      property :fsck_device, String, default: "-"
      property :fstype, [String, nil], default: "auto"

      property :options, [Array, String, nil],
        coerce: proc { |arg| arg.kind_of?(String) ? arg.split(",") : arg },
        default: %w{defaults}

      property :dump, [Integer, FalseClass], default: 0
      property :pass, [Integer, FalseClass], default: 2
      property :mounted, [TrueClass, FalseClass], default: false
      property :enabled, [TrueClass, FalseClass], default: false
      property :username, String
      property :domain, String

      private

      # Used by the AIX provider to set fstype to nil.
      # TODO use property to make nil a valid value for fstype
      def clear_fstype
        @fstype = nil
      end

    end
  end
end