microwave 0.1004.4 → 0.1004.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -3
- data/lib/chef/client.rb +2 -11
- data/lib/chef/platform.rb +1 -192
- data/lib/chef/providers.rb +0 -68
- data/lib/chef/resources.rb +0 -36
- data/lib/chef/version.rb +1 -1
- metadata +123 -239
- data/lib/chef/provider/breakpoint.rb +0 -31
- data/lib/chef/provider/cron.rb +0 -186
- data/lib/chef/provider/cron/solaris.rb +0 -195
- data/lib/chef/provider/deploy.rb +0 -343
- data/lib/chef/provider/deploy/revision.rb +0 -80
- data/lib/chef/provider/deploy/timestamped.rb +0 -33
- data/lib/chef/provider/env.rb +0 -152
- data/lib/chef/provider/env/windows.rb +0 -75
- data/lib/chef/provider/erl_call.rb +0 -101
- data/lib/chef/provider/git.rb +0 -243
- data/lib/chef/provider/group.rb +0 -133
- data/lib/chef/provider/group/aix.rb +0 -70
- data/lib/chef/provider/group/dscl.rb +0 -121
- data/lib/chef/provider/group/gpasswd.rb +0 -53
- data/lib/chef/provider/group/groupadd.rb +0 -81
- data/lib/chef/provider/group/pw.rb +0 -84
- data/lib/chef/provider/group/suse.rb +0 -53
- data/lib/chef/provider/group/usermod.rb +0 -57
- data/lib/chef/provider/group/windows.rb +0 -79
- data/lib/chef/provider/ifconfig.rb +0 -134
- data/lib/chef/provider/log.rb +0 -54
- data/lib/chef/provider/mdadm.rb +0 -91
- data/lib/chef/provider/mount.rb +0 -114
- data/lib/chef/provider/mount/mount.rb +0 -240
- data/lib/chef/provider/mount/windows.rb +0 -81
- data/lib/chef/provider/ohai.rb +0 -42
- data/lib/chef/provider/package.rb +0 -163
- data/lib/chef/provider/package/apt.rb +0 -135
- data/lib/chef/provider/package/dpkg.rb +0 -115
- data/lib/chef/provider/package/easy_install.rb +0 -136
- data/lib/chef/provider/package/freebsd.rb +0 -125
- data/lib/chef/provider/package/macports.rb +0 -105
- data/lib/chef/provider/package/pacman.rb +0 -101
- data/lib/chef/provider/package/portage.rb +0 -135
- data/lib/chef/provider/package/rpm.rb +0 -104
- data/lib/chef/provider/package/rubygems.rb +0 -465
- data/lib/chef/provider/package/solaris.rb +0 -130
- data/lib/chef/provider/package/yum.rb +0 -1128
- data/lib/chef/provider/package/zypper.rb +0 -144
- data/lib/chef/provider/route.rb +0 -193
- data/lib/chef/provider/ruby_block.rb +0 -34
- data/lib/chef/provider/script.rb +0 -55
- data/lib/chef/provider/service.rb +0 -122
- data/lib/chef/provider/service/arch.rb +0 -116
- data/lib/chef/provider/service/debian.rb +0 -130
- data/lib/chef/provider/service/freebsd.rb +0 -154
- data/lib/chef/provider/service/gentoo.rb +0 -53
- data/lib/chef/provider/service/init.rb +0 -71
- data/lib/chef/provider/service/insserv.rb +0 -52
- data/lib/chef/provider/service/redhat.rb +0 -60
- data/lib/chef/provider/service/simple.rb +0 -120
- data/lib/chef/provider/service/solaris.rb +0 -85
- data/lib/chef/provider/service/systemd.rb +0 -102
- data/lib/chef/provider/service/upstart.rb +0 -198
- data/lib/chef/provider/service/windows.rb +0 -146
- data/lib/chef/provider/subversion.rb +0 -197
- data/lib/chef/provider/user.rb +0 -186
- data/lib/chef/provider/user/dscl.rb +0 -280
- data/lib/chef/provider/user/pw.rb +0 -113
- data/lib/chef/provider/user/useradd.rb +0 -137
- data/lib/chef/provider/user/windows.rb +0 -124
- data/lib/chef/resource/apt_package.rb +0 -34
- data/lib/chef/resource/bash.rb +0 -33
- data/lib/chef/resource/breakpoint.rb +0 -35
- data/lib/chef/resource/cron.rb +0 -188
- data/lib/chef/resource/csh.rb +0 -33
- data/lib/chef/resource/deploy.rb +0 -380
- data/lib/chef/resource/deploy_revision.rb +0 -40
- data/lib/chef/resource/dpkg_package.rb +0 -34
- data/lib/chef/resource/easy_install_package.rb +0 -57
- data/lib/chef/resource/erl_call.rb +0 -83
- data/lib/chef/resource/freebsd_package.rb +0 -35
- data/lib/chef/resource/gem_package.rb +0 -53
- data/lib/chef/resource/git.rb +0 -46
- data/lib/chef/resource/group.rb +0 -70
- data/lib/chef/resource/ifconfig.rb +0 -134
- data/lib/chef/resource/log.rb +0 -62
- data/lib/chef/resource/macports_package.rb +0 -29
- data/lib/chef/resource/mdadm.rb +0 -82
- data/lib/chef/resource/mount.rb +0 -134
- data/lib/chef/resource/ohai.rb +0 -40
- data/lib/chef/resource/package.rb +0 -80
- data/lib/chef/resource/pacman_package.rb +0 -33
- data/lib/chef/resource/perl.rb +0 -33
- data/lib/chef/resource/portage_package.rb +0 -33
- data/lib/chef/resource/python.rb +0 -33
- data/lib/chef/resource/route.rb +0 -135
- data/lib/chef/resource/rpm_package.rb +0 -34
- data/lib/chef/resource/ruby.rb +0 -33
- data/lib/chef/resource/ruby_block.rb +0 -40
- data/lib/chef/resource/scm.rb +0 -147
- data/lib/chef/resource/script.rb +0 -60
- data/lib/chef/resource/service.rb +0 -160
- data/lib/chef/resource/solaris_package.rb +0 -36
- data/lib/chef/resource/subversion.rb +0 -36
- data/lib/chef/resource/timestamped_deploy.rb +0 -31
- data/lib/chef/resource/user.rb +0 -130
- data/lib/chef/resource/yum_package.rb +0 -63
data/lib/chef/provider/mdadm.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 Joe Williams
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/log'
|
20
|
-
require 'chef/mixin/shell_out'
|
21
|
-
require 'chef/provider'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Mdadm < Chef::Provider
|
26
|
-
|
27
|
-
#include Chef::Mixin::Command
|
28
|
-
include Chef::Mixin::ShellOut
|
29
|
-
|
30
|
-
def popen4
|
31
|
-
raise Exception, "deprecated, bitches"
|
32
|
-
end
|
33
|
-
|
34
|
-
def load_current_resource
|
35
|
-
@current_resource = Chef::Resource::Mdadm.new(@new_resource.name)
|
36
|
-
@current_resource.raid_device(@new_resource.raid_device)
|
37
|
-
Chef::Log.debug("#{@new_resource} checking for software raid device #{@current_resource.raid_device}")
|
38
|
-
|
39
|
-
mdadm = shell_out!("mdadm --detail --scan")
|
40
|
-
exists = mdadm.stdout.include?(@new_resource.raid_device)
|
41
|
-
#exists = false
|
42
|
-
# popen4(command) do |pid, stdin, stdout, stderr|
|
43
|
-
# stdout.each do |line|
|
44
|
-
# if line.include? @new_resource.raid_device
|
45
|
-
# exists = true
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
# end
|
49
|
-
@current_resource.exists(exists)
|
50
|
-
end
|
51
|
-
|
52
|
-
def action_create
|
53
|
-
unless @current_resource.exists
|
54
|
-
command = "yes | mdadm --create #{@new_resource.raid_device} --chunk=#{@new_resource.chunk} --level #{@new_resource.level} --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}"
|
55
|
-
Chef::Log.debug("#{@new_resource} mdadm command: #{command}")
|
56
|
-
#pid, stdin, stdout, stderr = popen4(command)
|
57
|
-
shell_out!(command)
|
58
|
-
Chef::Log.info("#{@new_resource} created raid device (#{@new_resource.raid_device})")
|
59
|
-
@new_resource.updated_by_last_action(true)
|
60
|
-
else
|
61
|
-
Chef::Log.debug("#{@new_resource} raid device already exists, skipping create (#{@new_resource.raid_device})")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def action_assemble
|
66
|
-
unless @current_resource.exists
|
67
|
-
command = "yes | mdadm --assemble #{@new_resource.raid_device} #{@new_resource.devices.join(" ")}"
|
68
|
-
Chef::Log.debug("#{@new_resource} mdadm command: #{command}")
|
69
|
-
shell_out!(command)
|
70
|
-
Chef::Log.info("#{@new_resource} assembled raid device (#{@new_resource.raid_device})")
|
71
|
-
@new_resource.updated_by_last_action(true)
|
72
|
-
else
|
73
|
-
Chef::Log.debug("#{@new_resource} raid device already exists, skipping assemble (#{@new_resource.raid_device})")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def action_stop
|
78
|
-
if @current_resource.exists
|
79
|
-
command = "yes | mdadm --stop #{@new_resource.raid_device}"
|
80
|
-
Chef::Log.debug("#{@new_resource} mdadm command: #{command}")
|
81
|
-
shell_out!(command)
|
82
|
-
Chef::Log.info("#{@new_resource} stopped raid device (#{@new_resource.raid_device})")
|
83
|
-
@new_resource.updated_by_last_action(true)
|
84
|
-
else
|
85
|
-
Chef::Log.debug("#{@new_resource} raid device doesn't exist (#{@new_resource.raid_device}) - not stopping")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
data/lib/chef/provider/mount.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 Opscode, Inc
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/log'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
require 'chef/provider'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Mount < Chef::Provider
|
26
|
-
|
27
|
-
include Chef::Mixin::Command
|
28
|
-
|
29
|
-
def action_mount
|
30
|
-
unless @current_resource.mounted
|
31
|
-
status = $testrun || mount_fs()
|
32
|
-
if status
|
33
|
-
@new_resource.updated_by_last_action(true)
|
34
|
-
Chef::Log.info("#{@new_resource} mounted")
|
35
|
-
end
|
36
|
-
else
|
37
|
-
Chef::Log.debug("#{@new_resource} is already mounted")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def action_umount
|
42
|
-
if @current_resource.mounted
|
43
|
-
status = $testrun || umount_fs()
|
44
|
-
if status
|
45
|
-
@new_resource.updated_by_last_action(true)
|
46
|
-
Chef::Log.info("#{@new_resource} unmounted")
|
47
|
-
end
|
48
|
-
else
|
49
|
-
Chef::Log.debug("#{@new_resource} is already unmounted")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def action_remount
|
54
|
-
unless @new_resource.supports[:remount]
|
55
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
|
56
|
-
else
|
57
|
-
if @current_resource.mounted
|
58
|
-
status = $testrun || remount_fs()
|
59
|
-
if status
|
60
|
-
@new_resource.updated_by_last_action(true)
|
61
|
-
Chef::Log.info("#{@new_resource} remounted")
|
62
|
-
end
|
63
|
-
else
|
64
|
-
Chef::Log.debug("#{@new_resource} not mounted, nothing to remount")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def action_enable
|
70
|
-
unless @current_resource.enabled
|
71
|
-
status = $testrun || enable_fs
|
72
|
-
if status
|
73
|
-
@new_resource.updated_by_last_action(true)
|
74
|
-
Chef::Log.info("#{@new_resource} enabled")
|
75
|
-
else
|
76
|
-
Chef::Log.debug("#{@new_resource} already enabled")
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def action_disable
|
82
|
-
if @current_resource.enabled
|
83
|
-
status = $testrun || disable_fs
|
84
|
-
if status
|
85
|
-
@new_resource.updated_by_last_action(true)
|
86
|
-
Chef::Log.info("#{@new_resource} disabled")
|
87
|
-
else
|
88
|
-
Chef::Log.debug("#{@new_resource} already disabled")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def mount_fs
|
94
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :mount"
|
95
|
-
end
|
96
|
-
|
97
|
-
def umount_fs
|
98
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :umount"
|
99
|
-
end
|
100
|
-
|
101
|
-
def remount_fs
|
102
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
|
103
|
-
end
|
104
|
-
|
105
|
-
def enable_fs
|
106
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"
|
107
|
-
end
|
108
|
-
|
109
|
-
def disable_fs
|
110
|
-
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,240 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 Opscode, Inc
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/mount'
|
20
|
-
require 'chef/log'
|
21
|
-
require 'chef/mixin/shell_out'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Mount
|
26
|
-
class Mount < Chef::Provider::Mount
|
27
|
-
include Chef::Mixin::ShellOut
|
28
|
-
|
29
|
-
def initialize(new_resource, run_context)
|
30
|
-
super
|
31
|
-
@real_device = nil
|
32
|
-
end
|
33
|
-
attr_accessor :real_device
|
34
|
-
|
35
|
-
def load_current_resource
|
36
|
-
@current_resource = Chef::Resource::Mount.new(@new_resource.name)
|
37
|
-
@current_resource.mount_point(@new_resource.mount_point)
|
38
|
-
@current_resource.device(@new_resource.device)
|
39
|
-
mounted?
|
40
|
-
enabled?
|
41
|
-
end
|
42
|
-
|
43
|
-
def mountable?
|
44
|
-
# only check for existence of non-remote devices
|
45
|
-
if (device_should_exist? && !::File.exists?(device_real) )
|
46
|
-
raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist"
|
47
|
-
elsif( !::File.exists?(@new_resource.mount_point) )
|
48
|
-
raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist"
|
49
|
-
end
|
50
|
-
return true
|
51
|
-
end
|
52
|
-
|
53
|
-
def enabled?
|
54
|
-
# Check to see if there is a entry in /etc/fstab. Last entry for a volume wins.
|
55
|
-
enabled = false
|
56
|
-
::File.foreach("/etc/fstab") do |line|
|
57
|
-
case line
|
58
|
-
when /^[#\s]/
|
59
|
-
next
|
60
|
-
when /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
|
61
|
-
enabled = true
|
62
|
-
@current_resource.fstype($1)
|
63
|
-
@current_resource.options($2)
|
64
|
-
@current_resource.dump($3.to_i)
|
65
|
-
@current_resource.pass($4.to_i)
|
66
|
-
Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/fstab")
|
67
|
-
next
|
68
|
-
when /^[\/\w]+\s+#{Regexp.escape(@new_resource.mount_point)}\s+/
|
69
|
-
enabled = false
|
70
|
-
Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/fstab")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
@current_resource.enabled(enabled)
|
74
|
-
end
|
75
|
-
|
76
|
-
def mounted?
|
77
|
-
mounted = false
|
78
|
-
shell_out!("mount").stdout.each_line do |line|
|
79
|
-
case line
|
80
|
-
when /^#{device_mount_regex}\s+on\s+#{Regexp.escape(@new_resource.mount_point)}/
|
81
|
-
mounted = true
|
82
|
-
Chef::Log.debug("Special device #{device_logstring} mounted as #{@new_resource.mount_point}")
|
83
|
-
when /^([\/\w])+\son\s#{Regexp.escape(@new_resource.mount_point)}\s+/
|
84
|
-
mounted = false
|
85
|
-
Chef::Log.debug("Special device #{$~[1]} mounted as #{@new_resource.mount_point}")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
@current_resource.mounted(mounted)
|
89
|
-
end
|
90
|
-
|
91
|
-
def mount_fs
|
92
|
-
unless @current_resource.mounted
|
93
|
-
mountable?
|
94
|
-
command = "mount -t #{@new_resource.fstype}"
|
95
|
-
command << " -o #{@new_resource.options.join(',')}" unless @new_resource.options.nil? || @new_resource.options.empty?
|
96
|
-
command << case @new_resource.device_type
|
97
|
-
when :device
|
98
|
-
" #{device_real}"
|
99
|
-
when :label
|
100
|
-
" -L #{@new_resource.device}"
|
101
|
-
when :uuid
|
102
|
-
" -U #{@new_resource.device}"
|
103
|
-
end
|
104
|
-
command << " #{@new_resource.mount_point}"
|
105
|
-
shell_out!(command)
|
106
|
-
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
|
107
|
-
else
|
108
|
-
Chef::Log.debug("#{@new_resource} is already mounted at #{@new_resource.mount_point}")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def umount_fs
|
113
|
-
if @current_resource.mounted
|
114
|
-
shell_out!("umount #{@new_resource.mount_point}")
|
115
|
-
Chef::Log.debug("#{@new_resource} is no longer mounted at #{@new_resource.mount_point}")
|
116
|
-
else
|
117
|
-
Chef::Log.debug("#{@new_resource} is not mounted at #{@new_resource.mount_point}")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def remount_fs
|
122
|
-
if @current_resource.mounted and @new_resource.supports[:remount]
|
123
|
-
shell_out!("mount -o remount #{@new_resource.mount_point}")
|
124
|
-
@new_resource.updated_by_last_action(true)
|
125
|
-
Chef::Log.debug("#{@new_resource} is remounted at #{@new_resource.mount_point}")
|
126
|
-
elsif @current_resource.mounted
|
127
|
-
umount_fs
|
128
|
-
sleep 1
|
129
|
-
mount_fs
|
130
|
-
else
|
131
|
-
Chef::Log.debug("#{@new_resource} is not mounted at #{@new_resource.mount_point} - nothing to do")
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def enable_fs
|
136
|
-
if @current_resource.enabled && mount_options_unchanged?
|
137
|
-
Chef::Log.debug("#{@new_resource} is already enabled - nothing to do")
|
138
|
-
return nil
|
139
|
-
end
|
140
|
-
|
141
|
-
if @current_resource.enabled
|
142
|
-
# The current options don't match what we have, so
|
143
|
-
# disable, then enable.
|
144
|
-
disable_fs
|
145
|
-
end
|
146
|
-
::File.open("/etc/fstab", "a") do |fstab|
|
147
|
-
fstab.puts("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? "defaults" : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
|
148
|
-
Chef::Log.debug("#{@new_resource} is enabled at #{@new_resource.mount_point}")
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def disable_fs
|
153
|
-
if @current_resource.enabled
|
154
|
-
contents = []
|
155
|
-
|
156
|
-
found = false
|
157
|
-
::File.readlines("/etc/fstab").reverse_each do |line|
|
158
|
-
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}/
|
159
|
-
found = true
|
160
|
-
Chef::Log.debug("#{@new_resource} is removed from fstab")
|
161
|
-
next
|
162
|
-
else
|
163
|
-
contents << line
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
::File.open("/etc/fstab", "w") do |fstab|
|
168
|
-
contents.reverse_each { |line| fstab.puts line}
|
169
|
-
end
|
170
|
-
else
|
171
|
-
Chef::Log.debug("#{@new_resource} is not enabled - nothing to do")
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def device_should_exist?
|
176
|
-
@new_resource.device !~ /:/ && @new_resource.device !~ /\/\// && @new_resource.device != "tmpfs" && @new_resource.fstype != 'fuse'
|
177
|
-
end
|
178
|
-
|
179
|
-
private
|
180
|
-
|
181
|
-
def device_fstab
|
182
|
-
case @new_resource.device_type
|
183
|
-
when :device
|
184
|
-
@new_resource.device
|
185
|
-
when :label
|
186
|
-
"LABEL=#{@new_resource.device}"
|
187
|
-
when :uuid
|
188
|
-
"UUID=#{@new_resource.device}"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def device_real
|
193
|
-
if @real_device == nil
|
194
|
-
if @new_resource.device_type == :device
|
195
|
-
@real_device = @new_resource.device
|
196
|
-
else
|
197
|
-
@real_device = ""
|
198
|
-
status = popen4("/sbin/findfs #{device_fstab}") do |pid, stdin, stdout, stderr|
|
199
|
-
device_line = stdout.first # stdout.first consumes
|
200
|
-
@real_device = device_line.chomp unless device_line.nil?
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
@real_device
|
205
|
-
end
|
206
|
-
|
207
|
-
def device_logstring
|
208
|
-
case @new_resource.device_type
|
209
|
-
when :device
|
210
|
-
"#{device_real}"
|
211
|
-
when :label
|
212
|
-
"#{device_real} with label #{@new_resource.device}"
|
213
|
-
when :uuid
|
214
|
-
"#{device_real} with uuid #{@new_resource.device}"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
def device_mount_regex
|
219
|
-
::File.symlink?(device_real) ? "(?:#{Regexp.escape(device_real)})|(?:#{Regexp.escape(::File.readlink(device_real))})" : Regexp.escape(device_real)
|
220
|
-
end
|
221
|
-
|
222
|
-
def device_fstab_regex
|
223
|
-
if @new_resource.device_type == :device
|
224
|
-
device_mount_regex
|
225
|
-
else
|
226
|
-
device_fstab
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
def mount_options_unchanged?
|
231
|
-
@current_resource.fstype == @new_resource.fstype and
|
232
|
-
@current_resource.options == @new_resource.options and
|
233
|
-
@current_resource.dump == @new_resource.dump and
|
234
|
-
@current_resource.pass == @new_resource.pass
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
-
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/mount'
|
20
|
-
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
21
|
-
require 'chef/util/windows/net_use'
|
22
|
-
require 'chef/util/windows/volume'
|
23
|
-
end
|
24
|
-
|
25
|
-
class Chef
|
26
|
-
class Provider
|
27
|
-
class Mount
|
28
|
-
class Windows < Chef::Provider::Mount
|
29
|
-
|
30
|
-
def is_volume(name)
|
31
|
-
name =~ /^\\\\\?\\Volume\{[\w-]+\}\\$/ ? true : false
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize(new_resource, run_context)
|
35
|
-
super
|
36
|
-
@mount = nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def load_current_resource
|
40
|
-
if is_volume(@new_resource.device)
|
41
|
-
@mount = Chef::Util::Windows::Volume.new(@new_resource.name)
|
42
|
-
else #assume network drive
|
43
|
-
@mount = Chef::Util::Windows::NetUse.new(@new_resource.name)
|
44
|
-
end
|
45
|
-
|
46
|
-
@current_resource = Chef::Resource::Mount.new(@new_resource.name)
|
47
|
-
@current_resource.mount_point(@new_resource.mount_point)
|
48
|
-
Chef::Log.debug("Checking for mount point #{@current_resource.mount_point}")
|
49
|
-
|
50
|
-
begin
|
51
|
-
@current_resource.device(@mount.device)
|
52
|
-
Chef::Log.debug("#{@current_resource.device} mounted on #{@new_resource.mount_point}")
|
53
|
-
@current_resource.mounted(true)
|
54
|
-
rescue ArgumentError => e
|
55
|
-
@current_resource.mounted(false)
|
56
|
-
Chef::Log.debug("#{@new_resource.mount_point} is not mounted: #{e.message}")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def mount_fs
|
61
|
-
unless @current_resource.mounted
|
62
|
-
@mount.add(@new_resource.device)
|
63
|
-
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
|
64
|
-
else
|
65
|
-
Chef::Log.debug("#{@new_resource} is already mounted at #{@new_resource.mount_point}")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def umount_fs
|
70
|
-
if @current_resource.mounted
|
71
|
-
@mount.delete
|
72
|
-
Chef::Log.debug("#{@new_resource} is no longer mounted at #{@new_resource.mount_point}")
|
73
|
-
else
|
74
|
-
Chef::Log.debug("#{@new_resource} is not mounted at #{@new_resource.mount_point}")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|