puppetlabs / Puppet.Dsc

Convert DSC resources into Puppet Resource API types and providers
https://www.powershellgallery.com/packages/Puppet.Dsc
Apache License 2.0
9 stars 12 forks source link

mandatory_for_get parameter not being passed to invocable_resource #224

Closed jrdbarnes closed 2 years ago

jrdbarnes commented 2 years ago

Describe the Bug

A parameter with mandatory_for_get: true is not passed to the Get-TargetResource call.

Expected Behavior

With the configuration defined below, dsc_endpointtype should be passed to the Get-TargetResource for execution.

Steps to Reproduce

With the following valid puppet resource definition, and dsc-sqlserverdsc module.

dsc_sqlendpoint {'HADREndpoint':
    validation_mode  => 'resource',  # tried both ways
    dsc_endpointname => 'HADR',
    dsc_endpointtype => 'DatabaseMirroring',
    dsc_ensure       => 'Present',
    dsc_port         =>  5022,
    dsc_servername   => $trusted['hostname'],
    dsc_instancename => 'MSSQLSERVER',
}

Install SQL on a Windows Server 2019 OS and run puppet.

Environment

Additional Context

The parameter definition from the Resource Definition inside the module:

    dsc_endpointtype: {^M
      type: "Enum['DatabaseMirroring', 'ServiceBroker']",^M
      desc: 'Specifies the type of endpoint. Currently the only types that are supported are the _Database Mirroring_ and the _Service Broker_ type.',^M
^M
      mandatory_for_get: true,^M
      mandatory_for_set: true,^M
      mof_type: 'String',^M
      mof_is_embedded: false,^M
    },

Abbreviated Debug logs:

Debug: dsc_sqlendpoint: Collecting data from the DSC Resource Debug: dsc_sqlendpoint: retrieving {:name=>"HADREndpoint", :dsc_instancename=>"MSSQLSERVER", :dsc_endpointname=>"HADR"} Debug: dsc_sqlendpoint: invocable_resource: {:parameters=>{:dsc_instancename=>{:value=>"MSSQLSERVER", :mof_type=>"String", :mof_is_embedded=>false}, :dsc_endpointname=>{:value=>"HADR", :mof_type=>"String", :mof_is_embedded=>false}}, :name=>"dsc_sqlendpoint", :dscmeta_resource_friendly_name=>"SqlEndpoint", :dscmeta_resource_name=>"DSC_SqlEndpoint", :dscmeta_resource_implementation=>"MOF", :dscmeta_module_name=>"SqlServerDsc", :dscmeta_module_version=>"15.2.0", :dsc_invoke_method=>"get", :vendored_modules_path=>"C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet_x/sqlserverdsc/dsc_resources", :attributes=>nil} Debug: dsc_sqlendpoint: Script: ... Debug: dsc_sqlendpoint: raw data received: {"rebootrequired"=>false, "indesiredstate"=>false, "errormessage"=>"Could not find mandatory property EndpointType. Add this property and try again."} Error: dsc_sqlendpoint: Could not find mandatory property EndpointType. Add this property and try again. Error: /Stage[main]/Profile::Sqlavg/Dsc_sqlendpoint[HADREndpoint]: Could not evaluate: undefined method `[]' for nil:NilClass

jrdbarnes commented 2 years ago

This is the same issue as https://github.com/puppetlabs/Puppet.Dsc/issues/214, not sure which project is correct for this bug.

chelnak commented 2 years ago

Hey @jrdbarnes , is this still an issue for you?

pmcmaw commented 2 years ago

Hey @jrdbarnes I am going to close this issue. As you mentioned it is the same as #214 which has now been resolved.

If you disagree with my decision please feel free to reopen and let me know. Thank you for taking the time to raise this issue.