diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-09-04 12:05:25 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-09-19 12:48:08 -0700 |
commit | e473325de679718ab0695d4d3177eeeef20dc994 (patch) | |
tree | 87450c0f1e85094ab75cdcf354072202ade9ee52 /lib/chef/resource | |
parent | ce46528db4c9a7f06a34d16ee37017a59e8aab73 (diff) | |
download | chef-e473325de679718ab0695d4d3177eeeef20dc994.tar.gz |
DscScript resource will raise an error if dsc is not available
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/dsc_script.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb index 37546c3b6a..2972ace1aa 100644 --- a/lib/chef/resource/dsc_script.rb +++ b/lib/chef/resource/dsc_script.rb @@ -16,6 +16,8 @@ # limitations under the License. # +require 'chef/exceptions' + class Chef class Resource class DscScript < Chef::Resource @@ -26,7 +28,12 @@ class Chef super @allowed_actions.push(:run) @action = :run - provider(Chef::Provider::DscScript) + if(run_context && Chef::Platform.supports_dsc?(run_context.node)) + @provider = Chef::Provider::DscScript + else + raise Chef::Exceptions::NoProviderAvailable, + "#{powershell_info_str(run_context)}\nPowershell 4.0 or higher was not detected on your system and is required to use the dsc_script resource." + end end def code(arg=nil) @@ -118,6 +125,16 @@ class Chef :kind_of => [ Integer ] ) end + + private + + def powershell_info_str(run_context) + if run_context && run_context.node[:languages] && run_context.node[:languages][:powershell] + install_info = "Powershell #{run_context.node[:languages][:powershell][:version]} was found on the system." + else + install_info = 'Powershell was not found.' + end + end end end end |