puppetlabs / puppetlabs/ruby-pwsh
dsc_scheduledtask taskpath parameter should have mandatory_for_get: true
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 20
- Forks
- 27
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 4
Description
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 :(
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting dsc_base_provider.rb and how the dsc_taskpath parameter's mandatory_for_get metadata affects resource lookup. Reproduce the scheduled-task example from the issue, then verify that a task in a non-root path is retrieved correctly without repeated corrective changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100