summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/windows_ad_join.rb19
-rw-r--r--spec/unit/resource/windows_ad_join_spec.rb (renamed from spec/unit/resource/windows_ad_join.rb)4
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb
index 7c026dba28..4917fa6be1 100644
--- a/lib/chef/resource/windows_ad_join.rb
+++ b/lib/chef/resource/windows_ad_join.rb
@@ -47,7 +47,7 @@ class Chef
description: "The path to the OU where you would like to place the host."
property :reboot, Symbol,
- equal_to: [:immediate, :delayed, :never],
+ equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now],
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the Chef run completes), and :never (Don't reboot)",
description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the Chef run completes, or never. Note that a reboot is necessary for changes to take effect.",
default: :immediate
@@ -71,8 +71,8 @@ class Chef
raise "Failed to join the domain #{new_resource.domain_name}: #{ps_run.stderr}}" if ps_run.error?
unless new_resource.reboot == :never
- declare_resource(:reboot, "Reboot to join domain #{new_resource.domain_name}") do
- action new_resource.reboot
+ reboot "Reboot to join domain #{new_resource.domain_name}" do
+ action clarify_reboot(new_resource.reboot)
reason "Reboot to join domain #{new_resource.domain_name}"
end
end
@@ -86,6 +86,19 @@ class Chef
raise "Failed to check if the system is joined to the domain #{new_resource.domain_name}: #{node_domain.stderr}}" if node_domain.error?
node_domain.stdout.downcase.strip == new_resource.domain_name.downcase
end
+
+ # This resource historically took `:immediate` and `:delayed` as arguments to the reboot property but then
+ # tried to shove that straight to the `reboot` resource which objected strenuously
+ def clarify_reboot(reboot_action)
+ case reboot_action
+ when :immediate
+ :reboot_now
+ when :delayed
+ :request_reboot
+ else
+ reboot_action
+ end
+ end
end
end
end
diff --git a/spec/unit/resource/windows_ad_join.rb b/spec/unit/resource/windows_ad_join_spec.rb
index 6c0466e3f8..87dd83cd49 100644
--- a/spec/unit/resource/windows_ad_join.rb
+++ b/spec/unit/resource/windows_ad_join_spec.rb
@@ -40,9 +40,11 @@ describe Chef::Resource::WindowsAdJoin do
expect { resource.domain_name "example" }.to raise_error(ArgumentError)
end
- it "accepts :immediate, :delayed, or :never values for 'reboot' property" do
+ it "accepts :immediate, :reboot_now, :request_reboot, :delayed, or :never values for 'reboot' property" do
expect { resource.reboot :immediate }.not_to raise_error
expect { resource.reboot :delayed }.not_to raise_error
+ expect { resource.reboot :reboot_now }.not_to raise_error
+ expect { resource.reboot :request_reboot }.not_to raise_error
expect { resource.reboot :never }.not_to raise_error
expect { resource.reboot :nopenope }.to raise_error(ArgumentError)
end