Support ShouldProcess in Invoke-DscResource
when calling the Set method
#91
michaeltlombardi
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the current implementation of DSC, a user can:
But there's no way for a user to see how the set method would behave without actually running it. This functionality is particularly useful when inspecting the behavior (or misbehavior) of a resource interactively and when exploring implementations as a resource author.
It's also functionality that exists in many higher-order configuration management tools. With Puppet, users can specify the
--noop
flag. With Chef, users can specify the--why-run
flag. With CFEngine, users can specify the--dry-run
flag. With Ansible, users can specify the--check
and--diff
flags. With Salt, users can specifytest=True
.In PowerShell, there is already a functional abstraction for this in the form of ShouldProcess and the WhatIf and Confirm switch parameters. Support for this on the
Invoke-DscResource
cmdlet would both enable interactive users to check the behavior of DSC Resources and make supporting this functionality much easier for integrating vendors / higher order configuration management tools.Proposal
I propose that the
Invoke-DscResource
cmdlet be updated to support ShouldProcess, that ShouldProcess support should be extended to methods defined on PowerShell classes, and that guidance be added to help DSC Resource authors understand how they can write DSC Resources that use this behavior effectively.I haven't dug into the underlying code at all, but I suspect this is somewhat bigger than just adding ShouldProcess to the
Invoke-DscResource
cmdlet as I don't believe there is any current way to annotate that a PowerShell class method supports ShouldProcess behavior. I'm not sure on the implementation and whether it can be accomplished without the need for a$PSClass
variable similar to$PSCmdlet
.Beta Was this translation helpful? Give feedback.
All reactions