Class: Chef::Provider::DscResource
- Inherits:
-
Chef::Provider
- Object
- Chef::Provider
- Chef::Provider::DscResource
- Includes:
- Mixin::PowershellTypeCoercions
- Defined in:
- lib/chef/provider/dsc_resource.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(new_resource, run_context) ⇒ DscResource
constructor
A new instance of DscResource.
- #load_current_resource ⇒ Object
- #whyrun_supported? ⇒ Boolean
Methods included from Mixin::PowershellTypeCoercions
#translate_type, #type_coercions
Methods inherited from Chef::Provider
#action_nothing, #cleanup_after_converge, #converge_by, #events, #node, #process_resource_requirements, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, supports?, #whyrun_mode?
Methods included from Mixin::Provides
#node_map, #provides, #provides?
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(new_resource, run_context) ⇒ DscResource
Returns a new instance of DscResource.
31 32 33 34 35 |
# File 'lib/chef/provider/dsc_resource.rb', line 31 def initialize(new_resource, run_context) super @new_resource = new_resource @module_name = new_resource.module_name end |
Instance Method Details
#action_run ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/chef/provider/dsc_resource.rb', line 37 def action_run if ! test_resource converge_by(generate_description) do result = set_resource end end end |
#define_resource_requirements ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chef/provider/dsc_resource.rb', line 52 def define_resource_requirements requirements.assert(:run) do |a| a.assertion { supports_dsc_invoke_resource? } err = ["You must have Powershell version >= 5.0.10018.0 to use dsc_resource."] a. Chef::Exceptions::NoProviderAvailable, err a.whyrun err + ["Assuming a previous resource installs Powershell 5.0.10018.0 or higher."] a.block_action! end requirements.assert(:run) do |a| a.assertion { ['RefreshMode'] == 'Disabled' } err = ["The LCM must have its RefreshMode set to Disabled. "] a. Chef::Exceptions::NoProviderAvailable, err.join(' ') a.whyrun err + ["Assuming a previous resource sets the RefreshMode."] a.block_action! end end |
#load_current_resource ⇒ Object
45 46 |
# File 'lib/chef/provider/dsc_resource.rb', line 45 def load_current_resource end |
#whyrun_supported? ⇒ Boolean
48 49 50 |
# File 'lib/chef/provider/dsc_resource.rb', line 48 def whyrun_supported? true end |