ruby-pwsh
ruby-pwsh copied to clipboard
dsc_scheduledtask taskpath parameter should have mandatory_for_get: true
Describe the Bug
When trying to set a scheduled task in a different taskpath, the resource won't search in the right place to retrieve the resource information and will always apply the configuration.
Expected Behavior
When applying a scheduled task in a specific taskpath, it should not reapply at each run
Steps to Reproduce
Using computermanagementdsc module : https://forge.puppet.com/modules/dsc/computermanagementdsc/readme Using dsc_scheduledtask module
dsc_scheduledtask { "my_task":
dsc_ensure => present,
dsc_enable => true,
dsc_taskname => "my_task",
dsc_taskpath => '\\my_taskpath\\',
dsc_actionexecutable => 'ping.exe',
dsc_actionarguments => "localhost",
dsc_actionworkingpath => '',
dsc_scheduletype => 'daily',
dsc_daysinterval => 1,
}
This results in this output (at each run)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_daysinterval: dsc_daysinterval changed to 1 (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_taskpath: dsc_taskpath changed '\' to '\my_taskpath\' (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_scheduletype: dsc_scheduletype changed to 'daily' (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_enable: dsc_enable changed to 'true' (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_ensure: dsc_ensure changed 'Absent' to 'present' (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_actionexecutable: dsc_actionexecutable changed to 'ping.exe' (corrective)
Notice: /Stage[main]/Main/Node[default]/Dsc_scheduledtask[my_task]/dsc_actionarguments: dsc_actionarguments changed to 'localhost' (corrective)
Environment
- Version puppet 7.23
- Platform Windows 2022
Additional Context
The thing is that the data that are retrieved are mostly nil because it searches the task my_task
in default taskpath \
The dsc_taskpath parameter is declared as this in the module
dsc_taskpath: {
type: 'Optional[String]',
desc: 'The path to the task - defaults to the root directory.',
mandatory_for_get: false,
mandatory_for_set: false,
mof_type: 'String',
mof_is_embedded: false,
},
If I use mandatory_for_get: true
, it works as wanted.
However the module being auto generated I guess it should be set on the powershell side. Though given this problem occurs because of dsc_base_provider.rb way of working, and given it may be a breaking change on the powershell side, I'm not sure they would update this 🤷
There is this issue that could help but it does not seem to move since 5 years :(