New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a way to support export
scenario
#73
Comments
Is the idea to have return type of the export be an array of hashtables from the Get or a string representation of the resulting current configuration in JSON/YAML? |
Intent is that the output could be turned around and reused for get/set/test so needs to be a valid resource config. This means if it's an array of values, then the resource needs to have it's config as an array already. Thinking about this further, it may also make sense to support the case where |
Modeling this as a Restful API would make enumerating all instances of a given resource feel natural |
Thinking about this again today and considering the following use cases:
Case 1For this case, I think that to maintain backward compatibility with existing resources, it makes the most sense to assume that a resource can only return a single instance from a If the resource's manifest has a key that opts into a return-all functionality, like For example: # Get a single instance of an IIS site
dsc resource get --name Site --module Microsoft.IIS --properties "name=foo"
# Get all IIS sites (no parameters)
dsc resource get --name Site --module Microsoft.IIS
# Get all IIS sites (indicating flag)
dsc resource get --name Site --module Microsoft.IIS --all Case 2For retrieving all instances for multiple resources, I think it would be reasonable for the caller to just loop calls to foreach ($Resource in @('Site', 'ApplicationPool', 'Feature')) {
dsc resource get --name $Resource --module Microsoft.IIS --all
} Case 3To enumerate the current state of an arbitrary set of resources on the target and get the return output as a configuration document, I think you're correct that the I wonder if another approach, re-using the existing grouping model, is to have a built-in An example of a configuration for this purpose might be: # ./exportable.config.yaml
resources:
- name: my resources
type: DSC/ExportGroup
properties:
resources:
- name: Websites
type: Microsoft.IIS/Site
- name: App Pools
type: Microsoft.IIS/ApplicationPools
- name: IIS Features
type: Microsoft.IIS/Feature
dependsOn:
- '[DSC/AssertionGroup]IsWindows'
- name: IsWindows
type: DSC/AssertionGroup
properties:
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Example Variable
type: Microsoft.Windows/EnvironmentVariable
properties:
name: EXAMPLE
value: An arbitrary string
_ensure: present And a user would call it with: # Output to terminal
dsc config export --file ./exportable.config.yaml
# Capture in new config file
dsc config export --file ./exportable.config.yaml > webfarm.config.yaml When you call AsideAnother reason to support the "enumerate all instances of this resource" key in a resource manifest is to enable the caller to decide whether it wants to enumerate all of the instances of a resource at once or one at a time. Some resources might functionally have to enumerate the full list every time and filter it to only return the specified instance. If a configuration includes 2-3 of those resources, the performance impact might not be noticeable. If the configuration includes 20 of those resources, knowing whether it can intelligently decide to pre-cache the instances would be useful. That also enables improved integration with higher-order tools that also have a model for enumerating the full list of instances for a resource. It also makes DSC Resources more useful as investigative tools on a system. ConclusionI think adding a new config key for a resource to advertise whether it supports enumerating every instance of itself, an For a user who wants to enumerate the list of instances without worrying about the return information being a usable configuration document, calling |
From discussion today, it seems there are multiple parts here:
resources:
name: IIS
properties:
- website: A
foo: bar
- website: B
foo: a
- website: C
foo: C resources:
type: IIS
properties:
website: A
foo: bar
type: IIS
properties:
website: B
foo: a
type: IIS
properties:
website: C
foo: C We agreed to go with the 2nd option pending customer feedback. |
Thinking about this further, I think it may be better to start with an |
I think I'm not sure I see how we can support Edit for clarification: By this I mean that there's two operations a caller might want to perform on a resource:
This implies to me that the two operations are |
The specific requirement for @michaeltlombardi, good description of |
@michaeltlombardi just like get/set/test, the |
We're looking at the same thing over in WinGet for: And over at Dev Home for:
|
To clarify, I don't mean that there's no value in Another thought, there's no way for extant PowerShell DSC Resources to participate in this - would that require an overload for |
get all
scenarioexport
scenario
That would require:
|
Summary of the new feature / enhancement
Users want to manually configure an application/workload and get all the relevant configuration out and apply it to many other instances. Currently,
get
uses the supplied config as a filter. Also some resources likeregistry
andfile
wouldn't make sense to enumerate the whole registry or filesystem.Proposed technical implementation details (optional)
Propose an optional
export
method in addition toget
,set
, andtest
.dsc config export
would ensure all the resources in the config support this method otherwise it fails.The text was updated successfully, but these errors were encountered: