chef 11.14.0.alpha.2-x86-mingw32 → 11.14.0.alpha.3-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/chef-service-manager +1 -1
- data/lib/chef/application.rb +8 -2
- data/lib/chef/chef_fs/command_line.rb +4 -4
- data/lib/chef/chef_fs/file_system.rb +3 -3
- data/lib/chef/chef_fs/parallelizer.rb +66 -90
- data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +35 -0
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +279 -0
- data/lib/chef/config.rb +36 -2
- data/lib/chef/cookbook/cookbook_version_loader.rb +0 -1
- data/lib/chef/cookbook/synchronizer.rb +64 -42
- data/lib/chef/cookbook_uploader.rb +4 -25
- data/lib/chef/cookbook_version.rb +12 -11
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +18 -1
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -3
- data/lib/chef/knife/bootstrap.rb +23 -1
- data/lib/chef/knife/bootstrap/chef-aix.erb +58 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +16 -13
- data/lib/chef/knife/core/bootstrap_context.rb +25 -1
- data/lib/chef/knife/list.rb +9 -8
- data/lib/chef/knife/serve.rb +44 -0
- data/lib/chef/knife/show.rb +2 -3
- data/lib/chef/knife/ssh.rb +1 -0
- data/lib/chef/mixin/create_path.rb +20 -4
- data/lib/chef/node.rb +19 -3
- data/lib/chef/platform/provider_mapping.rb +0 -1
- data/lib/chef/platform/query_helpers.rb +4 -3
- data/lib/chef/provider/env/windows.rb +10 -3
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/mount.rb +84 -42
- data/lib/chef/provider/package/freebsd/base.rb +92 -0
- data/lib/chef/provider/package/freebsd/pkg.rb +113 -0
- data/lib/chef/provider/package/freebsd/pkgng.rb +80 -0
- data/lib/chef/provider/package/freebsd/port.rb +70 -0
- data/lib/chef/providers.rb +3 -1
- data/lib/chef/resource/chef_gem.rb +2 -1
- data/lib/chef/resource/freebsd_package.rb +39 -3
- data/lib/chef/resource/lwrp_base.rb +2 -2
- data/lib/chef/resource/mount.rb +9 -9
- data/lib/chef/util/threaded_job_queue.rb +61 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +2 -0
- data/lib/chef/whitelist.rb +82 -0
- data/lib/chef/win32/registry.rb +0 -1
- data/lib/chef/win32/version.rb +4 -3
- data/spec/functional/win32/versions_spec.rb +4 -4
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +4 -1
- data/spec/integration/knife/common_options_spec.rb +9 -9
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
- data/spec/integration/knife/deps_spec.rb +3 -0
- data/spec/integration/knife/list_spec.rb +3 -0
- data/spec/integration/knife/raw_spec.rb +5 -2
- data/spec/integration/knife/redirection_spec.rb +4 -1
- data/spec/integration/knife/serve_spec.rb +57 -0
- data/spec/integration/knife/show_spec.rb +3 -0
- data/spec/support/pedant/run_pedant.rb +1 -0
- data/spec/support/platform_helpers.rb +7 -5
- data/spec/support/shared/context/config.rb +21 -0
- data/spec/support/shared/functional/file_resource.rb +52 -0
- data/spec/unit/chef_fs/parallelizer.rb +482 -0
- data/spec/unit/client_spec.rb +4 -2
- data/spec/unit/config_spec.rb +66 -12
- data/spec/unit/knife/bootstrap_spec.rb +6 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +31 -1
- data/spec/unit/node_spec.rb +73 -3
- data/spec/unit/provider/mount_spec.rb +102 -79
- data/spec/unit/provider/package/{freebsd_spec.rb → freebsd/pkg_spec.rb} +19 -32
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +155 -0
- data/spec/unit/provider/package/freebsd/port_spec.rb +160 -0
- data/spec/unit/resource/chef_gem_spec.rb +5 -0
- data/spec/unit/resource/freebsd_package_spec.rb +63 -11
- data/spec/unit/resource/mount_spec.rb +11 -0
- data/spec/unit/role_spec.rb +5 -1
- data/spec/unit/run_lock_spec.rb +2 -0
- data/spec/unit/util/threaded_job_queue_spec.rb +51 -0
- data/spec/unit/version/platform_spec.rb +1 -1
- metadata +176 -161
- data/lib/chef/provider/package/freebsd.rb +0 -149
@@ -19,20 +19,23 @@ exists() {
|
|
19
19
|
fi
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if exists
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
<% if knife_config[:bootstrap_install_command] %>
|
23
|
+
<%= knife_config[:bootstrap_install_command] %>
|
24
|
+
<% else %>
|
25
|
+
install_sh="<%= knife_config[:bootstrap_url] ? knife_config[:bootstrap_url] : "https://www.opscode.com/chef/install.sh" %>"
|
26
|
+
version_string="-v <%= chef_version %>"
|
27
|
+
if ! exists /usr/bin/chef-client; then
|
28
|
+
echo "Installing Chef Client..."
|
29
|
+
if exists wget; then
|
30
|
+
bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_wget_options] %> ${install_sh} -O -) <%= latest_current_chef_version_string %>
|
31
|
+
elif exists curl; then
|
32
|
+
bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_curl_options] %> ${install_sh}) <%= latest_current_chef_version_string %>
|
33
|
+
else
|
34
|
+
echo "Neither wget nor curl found. Please install one and try again." >&2
|
35
|
+
exit 1
|
36
|
+
fi
|
34
37
|
fi
|
35
|
-
|
38
|
+
<% end %>
|
36
39
|
|
37
40
|
mkdir -p /etc/chef
|
38
41
|
|
@@ -101,10 +101,35 @@ CONFIG
|
|
101
101
|
@chef_config.key?(:knife) ? @chef_config[:knife] : {}
|
102
102
|
end
|
103
103
|
|
104
|
+
#
|
105
|
+
# This function is used by older bootstrap templates other than chef-full
|
106
|
+
# and potentially by custom templates as well hence it's logic needs to be
|
107
|
+
# preserved for backwards compatibility reasons until we hit Chef 12.
|
104
108
|
def chef_version
|
105
109
|
knife_config[:bootstrap_version] || Chef::VERSION
|
106
110
|
end
|
107
111
|
|
112
|
+
#
|
113
|
+
# chef version string to fetch the latest current version from omnitruck
|
114
|
+
# If user is on X.Y.Z bootstrap will use the latest X release
|
115
|
+
# X here can be 10 or 11
|
116
|
+
def latest_current_chef_version_string
|
117
|
+
chef_version_string = if knife_config[:bootstrap_version]
|
118
|
+
knife_config[:bootstrap_version]
|
119
|
+
else
|
120
|
+
Chef::VERSION.split(".").first
|
121
|
+
end
|
122
|
+
|
123
|
+
installer_version_string = ["-v", chef_version_string]
|
124
|
+
|
125
|
+
# If bootstrapping a pre-release version add -p to the installer string
|
126
|
+
if chef_version_string.split(".").length > 3
|
127
|
+
installer_version_string << "-p"
|
128
|
+
end
|
129
|
+
|
130
|
+
installer_version_string.join(" ")
|
131
|
+
end
|
132
|
+
|
108
133
|
def first_boot
|
109
134
|
(@config[:first_boot_attributes] || {}).merge(:run_list => @run_list)
|
110
135
|
end
|
@@ -113,4 +138,3 @@ CONFIG
|
|
113
138
|
end
|
114
139
|
end
|
115
140
|
end
|
116
|
-
|
data/lib/chef/knife/list.rb
CHANGED
@@ -43,21 +43,23 @@ class Chef
|
|
43
43
|
def run
|
44
44
|
patterns = name_args.length == 0 ? [""] : name_args
|
45
45
|
|
46
|
-
# Get the matches
|
47
|
-
|
48
|
-
|
46
|
+
# Get the top-level matches
|
47
|
+
args = pattern_args_from(patterns)
|
48
|
+
all_results = parallelize(pattern_args_from(patterns)) do |pattern|
|
49
|
+
pattern_results = Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern).to_a
|
49
50
|
if pattern_results.first && !pattern_results.first.exists? && pattern.exact_path
|
50
51
|
ui.error "#{format_path(pattern_results.first)}: No such file or directory"
|
51
52
|
self.exit_code = 1
|
52
53
|
end
|
53
54
|
pattern_results
|
54
|
-
end
|
55
|
+
end.flatten(1).to_a
|
55
56
|
|
56
57
|
# Process directories
|
57
58
|
if !config[:bare_directories]
|
58
|
-
dir_results = parallelize(all_results.select { |result| result.dir? }
|
59
|
+
dir_results = parallelize(all_results.select { |result| result.dir? }) do |result|
|
59
60
|
add_dir_result(result)
|
60
|
-
end.
|
61
|
+
end.flatten(1)
|
62
|
+
|
61
63
|
else
|
62
64
|
dir_results = []
|
63
65
|
end
|
@@ -109,7 +111,7 @@ class Chef
|
|
109
111
|
result = [ [ result, children ] ]
|
110
112
|
if config[:recursive]
|
111
113
|
child_dirs = children.select { |child| child.dir? }
|
112
|
-
result += parallelize(child_dirs
|
114
|
+
result += parallelize(child_dirs) { |child| add_dir_result(child) }.flatten(1).to_a
|
113
115
|
end
|
114
116
|
result
|
115
117
|
end
|
@@ -152,4 +154,3 @@ class Chef
|
|
152
154
|
end
|
153
155
|
end
|
154
156
|
end
|
155
|
-
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class Serve < Knife
|
6
|
+
option :repo_mode,
|
7
|
+
:long => '--repo-mode MODE',
|
8
|
+
:description => "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything"
|
9
|
+
|
10
|
+
option :chef_repo_path,
|
11
|
+
:long => '--chef-repo-path PATH',
|
12
|
+
:description => 'Overrides the location of chef repo. Default is specified by chef_repo_path in the config'
|
13
|
+
|
14
|
+
option :chef_zero_host,
|
15
|
+
:long => '--chef-zero-host IP',
|
16
|
+
:description => 'Overrides the host upon which chef-zero listens. Default is 127.0.0.1.'
|
17
|
+
|
18
|
+
def configure_chef
|
19
|
+
super
|
20
|
+
Chef::Config.local_mode = true
|
21
|
+
Chef::Config[:repo_mode] = config[:repo_mode] if config[:repo_mode]
|
22
|
+
|
23
|
+
# --chef-repo-path forcibly overrides all other paths
|
24
|
+
if config[:chef_repo_path]
|
25
|
+
Chef::Config.chef_repo_path = config[:chef_repo_path]
|
26
|
+
%w(acl client cookbook container data_bag environment group node role user).each do |variable_name|
|
27
|
+
Chef::Config.delete("#{variable_name}_path".to_sym)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
begin
|
34
|
+
server = Chef::Application.chef_zero_server
|
35
|
+
output "Serving files from:\n#{server.options[:data_store].chef_fs.fs_description}"
|
36
|
+
server.stop
|
37
|
+
server.start(stdout) # to print header
|
38
|
+
ensure
|
39
|
+
server.stop
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/chef/knife/show.rb
CHANGED
@@ -20,7 +20,7 @@ class Chef
|
|
20
20
|
def run
|
21
21
|
# Get the matches (recursively)
|
22
22
|
error = false
|
23
|
-
entry_values = parallelize(pattern_args
|
23
|
+
entry_values = parallelize(pattern_args) do |pattern|
|
24
24
|
parallelize(Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern)) do |entry|
|
25
25
|
if entry.dir?
|
26
26
|
ui.error "#{format_path(entry)}: is a directory" if pattern.exact_path
|
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
-
end
|
43
|
+
end.flatten(1)
|
44
44
|
entry_values.each do |entry, value|
|
45
45
|
if entry
|
46
46
|
output "#{format_path(entry)}:"
|
@@ -54,4 +54,3 @@ class Chef
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -44,14 +44,30 @@ class Chef
|
|
44
44
|
|
45
45
|
file_path.each_index do |i|
|
46
46
|
create_path = File.join(file_path[0, i + 1])
|
47
|
-
unless File.directory?(create_path)
|
48
|
-
Chef::Log.debug("Creating directory #{create_path}")
|
49
|
-
Dir.mkdir(create_path)
|
50
|
-
end
|
47
|
+
create_dir(create_path) unless File.directory?(create_path)
|
51
48
|
end
|
49
|
+
|
52
50
|
File.expand_path(File.join(file_path))
|
53
51
|
end
|
54
52
|
|
53
|
+
private
|
54
|
+
|
55
|
+
def create_dir(path)
|
56
|
+
begin
|
57
|
+
# When doing multithreaded downloads into the file cache, the following
|
58
|
+
# interleaving raises an error here:
|
59
|
+
#
|
60
|
+
# thread1 thread2
|
61
|
+
# File.directory?(create_path) <- false
|
62
|
+
# File.directory?(create_path) <- false
|
63
|
+
# Dir.mkdir(create_path)
|
64
|
+
# Dir.mkdir(create_path) <- raises Errno::EEXIST
|
65
|
+
Chef::Log.debug("Creating directory #{path}")
|
66
|
+
Dir.mkdir(path)
|
67
|
+
rescue Errno::EEXIST
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
55
71
|
end
|
56
72
|
end
|
57
73
|
end
|
data/lib/chef/node.rb
CHANGED
@@ -34,6 +34,7 @@ require 'chef/node/attribute'
|
|
34
34
|
require 'chef/mash'
|
35
35
|
require 'chef/json_compat'
|
36
36
|
require 'chef/search/query'
|
37
|
+
require 'chef/whitelist'
|
37
38
|
|
38
39
|
class Chef
|
39
40
|
class Node
|
@@ -520,18 +521,18 @@ class Chef
|
|
520
521
|
if Chef::Config[:why_run]
|
521
522
|
Chef::Log.warn("In whyrun mode, so NOT performing node save.")
|
522
523
|
else
|
523
|
-
chef_server_rest.put_rest("nodes/#{name}",
|
524
|
+
chef_server_rest.put_rest("nodes/#{name}", data_for_save)
|
524
525
|
end
|
525
526
|
rescue Net::HTTPServerException => e
|
526
527
|
raise e unless e.response.code == "404"
|
527
|
-
chef_server_rest.post_rest("nodes",
|
528
|
+
chef_server_rest.post_rest("nodes", data_for_save)
|
528
529
|
end
|
529
530
|
self
|
530
531
|
end
|
531
532
|
|
532
533
|
# Create the node via the REST API
|
533
534
|
def create
|
534
|
-
chef_server_rest.post_rest("nodes",
|
535
|
+
chef_server_rest.post_rest("nodes", data_for_save)
|
535
536
|
self
|
536
537
|
end
|
537
538
|
|
@@ -543,5 +544,20 @@ class Chef
|
|
543
544
|
self.name <=> other_node.name
|
544
545
|
end
|
545
546
|
|
547
|
+
private
|
548
|
+
|
549
|
+
def data_for_save
|
550
|
+
data = for_json
|
551
|
+
["automatic", "default", "normal", "override"].each do |level|
|
552
|
+
whitelist_config_option = "#{level}_attribute_whitelist".to_sym
|
553
|
+
whitelist = Chef::Config[whitelist_config_option]
|
554
|
+
unless whitelist.nil? # nil => save everything
|
555
|
+
Chef::Log.info("Whitelisting #{level} node attributes for save.")
|
556
|
+
data[level] = Chef::Whitelist.filter(data[level], whitelist)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
data
|
560
|
+
end
|
561
|
+
|
546
562
|
end
|
547
563
|
end
|
@@ -30,15 +30,16 @@ class Chef
|
|
30
30
|
|
31
31
|
def windows_server_2003?
|
32
32
|
return false unless windows?
|
33
|
-
require '
|
33
|
+
require 'wmi-lite/wmi'
|
34
34
|
|
35
35
|
# CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0
|
36
36
|
# https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db
|
37
37
|
# https://github.com/ruby/ruby/commit/27ed294c7134c0de582007af3c915a635a6506cd
|
38
38
|
WIN32OLE.ole_initialize
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
wmi = WmiLite::Wmi.new
|
41
|
+
host = wmi.first_of('Win32_OperatingSystem')
|
42
|
+
is_server_2003 = (host['version'] && host['version'].start_with?("5.2"))
|
42
43
|
|
43
44
|
WIN32OLE.ole_uninitialize
|
44
45
|
|
@@ -17,7 +17,6 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
20
|
-
require 'ruby-wmi'
|
21
20
|
require 'Win32API'
|
22
21
|
end
|
23
22
|
|
@@ -51,9 +50,17 @@ class Chef
|
|
51
50
|
return obj ? obj.variablevalue : nil
|
52
51
|
end
|
53
52
|
|
53
|
+
def find_env(environment_variables, key_name)
|
54
|
+
environment_variables.find do | environment_variable |
|
55
|
+
environment_variable['name'].downcase == key_name
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
54
59
|
def env_obj(key_name)
|
55
|
-
|
56
|
-
|
60
|
+
wmi = WmiLite::Wmi.new
|
61
|
+
environment_variables = wmi.instances_of('Win32_Environment')
|
62
|
+
existing_variable = find_env(environment_variables, key_name)
|
63
|
+
existing_variable.nil? ? nil : existing_variable.wmi_ole_object
|
57
64
|
end
|
58
65
|
|
59
66
|
#see: http://msdn.microsoft.com/en-us/library/ms682653%28VS.85%29.aspx
|
data/lib/chef/provider/file.rb
CHANGED
@@ -296,7 +296,7 @@ class Chef
|
|
296
296
|
def do_unlink
|
297
297
|
@file_unlinked = false
|
298
298
|
if @new_resource.force_unlink
|
299
|
-
if !real_file?(@new_resource.path)
|
299
|
+
if l_exist?(@new_resource.path) && !real_file?(@new_resource.path)
|
300
300
|
# unlink things that aren't normal files
|
301
301
|
description = "unlink #{file_type_string(@new_resource.path)} at #{@new_resource.path}"
|
302
302
|
converge_by(description) do
|
data/lib/chef/provider/mount.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Joshua Timberman (<joshua@
|
3
|
-
#
|
2
|
+
# Author:: Joshua Timberman (<joshua@getchef.com>)
|
3
|
+
# Author:: Lamont Granquist (<lamont@getchef.com>)
|
4
|
+
# Copyright:: Copyright (c) 2009-2014 Chef Software, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -26,6 +27,7 @@ class Chef
|
|
26
27
|
|
27
28
|
include Chef::Mixin::Command
|
28
29
|
|
30
|
+
attr_accessor :unmount_retries
|
29
31
|
|
30
32
|
def whyrun_supported?
|
31
33
|
true
|
@@ -35,94 +37,134 @@ class Chef
|
|
35
37
|
true
|
36
38
|
end
|
37
39
|
|
40
|
+
def initialize(new_resource, run_context)
|
41
|
+
super
|
42
|
+
self.unmount_retries = 20
|
43
|
+
end
|
44
|
+
|
38
45
|
def action_mount
|
39
|
-
unless
|
40
|
-
converge_by("mount #{
|
41
|
-
|
42
|
-
|
43
|
-
Chef::Log.info("#{@new_resource} mounted")
|
44
|
-
end
|
46
|
+
unless current_resource.mounted
|
47
|
+
converge_by("mount #{current_resource.device} to #{current_resource.mount_point}") do
|
48
|
+
mount_fs
|
49
|
+
Chef::Log.info("#{new_resource} mounted")
|
45
50
|
end
|
46
51
|
else
|
47
|
-
Chef::Log.debug("#{
|
52
|
+
Chef::Log.debug("#{new_resource} is already mounted")
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
51
56
|
def action_umount
|
52
|
-
if
|
53
|
-
converge_by("unmount #{
|
54
|
-
|
55
|
-
|
56
|
-
Chef::Log.info("#{@new_resource} unmounted")
|
57
|
-
end
|
57
|
+
if current_resource.mounted
|
58
|
+
converge_by("unmount #{current_resource.device}") do
|
59
|
+
umount_fs
|
60
|
+
Chef::Log.info("#{new_resource} unmounted")
|
58
61
|
end
|
59
62
|
else
|
60
|
-
Chef::Log.debug("#{
|
63
|
+
Chef::Log.debug("#{new_resource} is already unmounted")
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
def action_remount
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
status = remount_fs()
|
71
|
-
if status
|
72
|
-
Chef::Log.info("#{@new_resource} remounted")
|
73
|
-
end
|
68
|
+
if current_resource.mounted
|
69
|
+
if new_resource.supports[:remount]
|
70
|
+
converge_by("remount #{current_resource.device}") do
|
71
|
+
remount_fs
|
72
|
+
Chef::Log.info("#{new_resource} remounted")
|
74
73
|
end
|
75
74
|
else
|
76
|
-
|
75
|
+
converge_by("unmount #{current_resource.device}") do
|
76
|
+
umount_fs
|
77
|
+
Chef::Log.info("#{new_resource} unmounted")
|
78
|
+
end
|
79
|
+
wait_until_unmounted(unmount_retries)
|
80
|
+
converge_by("mount #{current_resource.device}") do
|
81
|
+
mount_fs
|
82
|
+
Chef::Log.info("#{new_resource} mounted")
|
83
|
+
end
|
77
84
|
end
|
85
|
+
else
|
86
|
+
Chef::Log.debug("#{new_resource} not mounted, nothing to remount")
|
78
87
|
end
|
79
88
|
end
|
80
89
|
|
81
90
|
def action_enable
|
82
|
-
unless
|
83
|
-
converge_by("
|
84
|
-
|
85
|
-
|
86
|
-
Chef::Log.info("#{@new_resource} enabled")
|
87
|
-
else
|
88
|
-
Chef::Log.debug("#{@new_resource} already enabled")
|
89
|
-
end
|
91
|
+
unless current_resource.enabled && mount_options_unchanged?
|
92
|
+
converge_by("enable #{current_resource.device}") do
|
93
|
+
enable_fs
|
94
|
+
Chef::Log.info("#{new_resource} enabled")
|
90
95
|
end
|
96
|
+
else
|
97
|
+
Chef::Log.debug("#{new_resource} already enabled")
|
91
98
|
end
|
92
99
|
end
|
93
100
|
|
94
101
|
def action_disable
|
95
|
-
if
|
96
|
-
converge_by("
|
97
|
-
|
98
|
-
|
99
|
-
Chef::Log.info("#{@new_resource} disabled")
|
100
|
-
else
|
101
|
-
Chef::Log.debug("#{@new_resource} already disabled")
|
102
|
-
end
|
102
|
+
if current_resource.enabled
|
103
|
+
converge_by("disable #{current_resource.device}") do
|
104
|
+
disable_fs
|
105
|
+
Chef::Log.info("#{new_resource} disabled")
|
103
106
|
end
|
107
|
+
else
|
108
|
+
Chef::Log.debug("#{new_resource} already disabled")
|
104
109
|
end
|
105
110
|
end
|
106
111
|
|
112
|
+
#
|
113
|
+
# Abstract Methods to be implemented by subclasses
|
114
|
+
#
|
115
|
+
|
116
|
+
# should actually check if the filesystem is mounted (not just return current_resource) and return true/false
|
117
|
+
def mounted?
|
118
|
+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not implement #mounted?"
|
119
|
+
end
|
120
|
+
|
121
|
+
# should check new_resource against current_resource to see if mount options need updating, returns true/false
|
122
|
+
def mount_options_unchanged?
|
123
|
+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not implement #mount_options_unchanged?"
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# NOTE: for the following methods, this superclass will already have checked if the filesystem is
|
128
|
+
# enabled and/or mounted and they will be called in converge_by blocks, so most defensive checking
|
129
|
+
# does not need to be done in the subclass implementation -- just do the thing.
|
130
|
+
#
|
131
|
+
|
132
|
+
# should implement mounting of the filesystem, raises if action does not succeed
|
107
133
|
def mount_fs
|
108
134
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :mount"
|
109
135
|
end
|
110
136
|
|
137
|
+
# should implement unmounting of the filesystem, raises if action does not succeed
|
111
138
|
def umount_fs
|
112
139
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :umount"
|
113
140
|
end
|
114
141
|
|
142
|
+
# should implement remounting of the filesystem (via a -o remount or some other atomic-ish action that isn't
|
143
|
+
# simply a umount/mount style remount), raises if action does not succeed
|
115
144
|
def remount_fs
|
116
145
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
|
117
146
|
end
|
118
147
|
|
148
|
+
# should implement enabling of the filesystem (e.g. in /etc/fstab), raises if action does not succeed
|
119
149
|
def enable_fs
|
120
150
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"
|
121
151
|
end
|
122
152
|
|
153
|
+
# should implement disabling of the filesystem (e.g. in /etc/fstab), raises if action does not succeed
|
123
154
|
def disable_fs
|
124
155
|
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"
|
125
156
|
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def wait_until_unmounted(tries)
|
161
|
+
while mounted?
|
162
|
+
if (tries -= 1) < 0
|
163
|
+
raise Chef::Exceptions::Mount, "Retries exceeded waiting for filesystem to unmount"
|
164
|
+
end
|
165
|
+
sleep 0.1
|
166
|
+
end
|
167
|
+
end
|
126
168
|
end
|
127
169
|
end
|
128
170
|
end
|