Add support for reporting how a DSC Resource's state changed via the Set method #78
michaeltlombardi
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I always thought of this as something the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the current implementation of DSC, after I call the
Set
method the only information I get back is a Boolean representation of whether the machine requires a reboot ($true
) or not ($false
). The only other information available to me is via the verbose and error streams.In my experience as a vendor and operator in the configuration management space, a critical piece of information for auditing is not just when or that a resource was modified but also how. There is currently no defined way for a DSC Resource invoked with the
Set
method to report which properties were changed from what state to what state in a straightforwardly retrievable way.This information is valuable both at the high-level/aggregate view (so patterns can be inspected and long-term reporting performed) and when an operator is interactively managing state (removing the need to call the
Get
method before and afterSet
to inspect state).Vendor Context
When I wrote the
puppet.dsc
module and the Puppet-side integration for DSC, I had to retrieve the current state, compare it to the user's desired state, and then use those values in my reporting instead of relying on DSC itself. This was somewhat fragile as direct comparisons are not always possible and I had no sensible way to programmatically retrieve that information across thousands of differently implemented DSC Resources.Proposal
For the sake of backwards-compatibility, I propose adding an optional switch parameter to return more detailed information when calling
Invoke-DscResource
with theSet
method. Possible names for this parameter include Detailed and WithChangeReport.However, as not all configuration items for a DSC Resource may be straightforwardly comparable to input values (e.g. when specifying the valid version range for a package), I further propose that this implementation use a new method in the class for a DSC Resource. For the sake of example, I'll refer to that method as SetDetailed from now on.
The SetDetailed method should perform the set operation and construct a hash table for the return (or, even better, return an instance of class defined for this purpose)
Example Return Objects
Enforced State
Already in Desired State
Failed to Enforce State
Alternative
As DSC v3 is already a strongly breaking change from prior versions and many resources will need to be rewritten, expect detailed information by default and fall back on the current return object if required.
Beta Was this translation helpful? Give feedback.
All reactions