Class: Chef::Provider::DscScript
- Inherits:
-
Chef::Provider
- Object
- Chef::Provider
- Chef::Provider::DscScript
- Defined in:
- lib/chef/provider/dsc_script.rb
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Attribute Summary
Attributes inherited from Chef::Provider
#action, #cookbook_name, #current_resource, #new_resource, #recipe_name, #run_context
Instance Method Summary collapse
- #action_run ⇒ Object
- #define_resource_requirements ⇒ Object
-
#initialize(dsc_resource, run_context) ⇒ DscScript
constructor
A new instance of DscScript.
- #load_current_resource ⇒ Object
- #whyrun_supported? ⇒ Boolean
Methods inherited from Chef::Provider
#action_nothing, #cleanup_after_converge, #converge_by, #events, #node, node_map, #process_resource_requirements, provides, provides?, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, supports?, #whyrun_mode?
Methods included from Mixin::DescendantsTracker
#descendants, descendants, direct_descendants, #direct_descendants, find_descendants_by_name, #find_descendants_by_name, #inherited, store_inherited
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!, #shell_out_with_systems_locale, #shell_out_with_systems_locale!
Constructor Details
#initialize(dsc_resource, run_context) ⇒ DscScript
Returns a new instance of DscScript.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chef/provider/dsc_script.rb', line 30 def initialize(dsc_resource, run_context) super(dsc_resource, run_context) @dsc_resource = dsc_resource @resource_converged = false @operations = { :set => Proc.new { |config_manager, document| config_manager.set_configuration(document) }, :test => Proc.new { |config_manager, document| config_manager.test_configuration(document) }} end |
Instance Method Details
#action_run ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/chef/provider/dsc_script.rb', line 43 def action_run if ! @resource_converged converge_by(generate_description) do run_configuration(:set) Chef::Log.info("DSC resource configuration completed successfully") end end end |
#define_resource_requirements ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/chef/provider/dsc_script.rb', line 65 def define_resource_requirements requirements.assert(:run) do |a| err = [ 'Could not find PowerShell DSC support on the system', powershell_info_str, "Powershell 4.0 or higher was not detected on your system and is required to use the dsc_script resource.", ] a.assertion { supports_dsc? } a. Chef::Exceptions::NoProviderAvailable, err.join(' ') a.whyrun err + ["Assuming a previous resource installs Powershell 4.0 or higher."] a.block_action! end end |
#load_current_resource ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/chef/provider/dsc_script.rb', line 52 def load_current_resource if supports_dsc? @dsc_resources_info = run_configuration(:test) @resource_converged = @dsc_resources_info.all? do |resource| !resource.changes_state? end end end |
#whyrun_supported? ⇒ Boolean
61 62 63 |
# File 'lib/chef/provider/dsc_script.rb', line 61 def whyrun_supported? true end |