Comments (8)
If I understand what you're trying to do, you want to use a resource that takes a single value and be able to specify an array so that single resource gets used for each element in the array? Basically like a pipeline?
from dsc.
If I understand what you're trying to do, you want to use a resource that takes a single value and be able to specify an array so that single resource gets used for each element in the array? Basically like a pipeline?
Exactly, the copying part is the key here.
from dsc.
I think this could potentially be solved with a group resource, rather than a configuration document engine feature. Something like...
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Use class PowerShell resources
type: Microsoft.DSC/PowerShell
properties:
resoureces:
- name: Create several groups
type: MyPsDscResources/Multiple:
properties:
ResourceType: PSDscResources/Group
SharedDefaultProperties:
Ensure: Present
InstanceProperties:
- GroupName: Group1
Members: User1, User2
- GroupName: Group2
Members: User1, User3, User4
To use a group like this with adapted resources, you would want an adapted group - otherwise you would end up generating multiple instances of the PowerShell adapter and incur that extra overhead.
But it could work similarly for non-adapted resources:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Manage registry keys
type: Microsoft.Dsc/MultiInstance:
properties:
type: Microsoft.Windows/Registry
sharedDefaultProperties:
_exist: true
keyPath: HKCU\DSC\Test
instanceProperties:
- valueName: Foo
- valueName: Bar
- valueName: Baz
valueData: { String: 'hello world' }
- keyPath: HKCU\DSC\Test\OverrideDefault
from dsc.
The concept makes sense to me and the example from @michaeltlombardi makes sense to me to use a new Group resource. I don't think MultiInstance
really describes the usage, maybe Microsoft.DSC/ForEach
? Some naming suggestions:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Manage registry keys
type: Microsoft.Dsc/ForEach
properties:
type: Microsoft.Windows/Registry
propertyDefaults:
_exist: true
keyPath: HKCU\DSC\Test
instanceProperties:
- valueName: Foo
- valueName: Bar
- valueName: Baz
valueData: { String: 'hello world' }
- keyPath: HKCU\DSC\Test\OverrideDefault
from dsc.
I get both the points and I definitely agree on the part that there shouldn't be too much overhead. If it solves the goal that the configuration document in itself can be dynamically filled and if it requires looping through the parameter keys to determine how many resources are required to be executed, I would be happy.
If you want me to explain it in more detail in DSC v2 concepts, I have a practical use case of what we've tried to achieve there.
@SteveL-MSFT , Microsoft.DSC/Foreach sounds good to me if it fits in the picture of ARM functionality, meaning if it cannot be solved from ARM functionality that's being built.
from dsc.
@Gijsreyn ForEach
would probably fit more with Bicep that would generate ARM and eventually we'd like to explore a Bicep extension to output DSC configuration. However, I don't think it would be much effort to create this resource, so I might give it a shot between other work items.
from dsc.
Looking into ARM, I see I missed one important detail which is ARM currently supports the idea of copy
which was the original request. So if we want to align with ARM, then we would use their syntax rather than invent something new (although the two aren't mutually exclusive). Looking at the ARM example for copy
, it doesn't look very user friendly at all...
from dsc.
Looking into ARM, I see I missed one important detail which is ARM currently supports the idea of
copy
which was the original request. So if we want to align with ARM, then we would use their syntax rather than invent something new (although the two aren't mutually exclusive). Looking at the ARM example forcopy
, it doesn't look very user friendly at all...
I fully agree and it might be confusing on the naming when ForEach is used. Something to look into ...
from dsc.
Related Issues (20)
- No error when invalid adapter name is provided
- Better error when no input is provided to `test` on a resource
- Pending reboot should have embedded schema for assertions
- PSDSCAdapter cannot process argument transformation HOT 2
- Remove static validation of input HOT 4
- Large output not returned HOT 2
- `dsc` should add it's home directory to `PATH` to find included resources
- Cache entry path not found
- Export operation method cannot be called on a null-valued expression HOT 2
- Expressions is missing array index support
- Duplicates allowed for parameters and values (or any HashMap) HOT 3
- Need to support getting traces from child `dsc` processes HOT 7
- `exporter` kind of resource HOT 3
- Better error message when no input is provided to PowerShell adapters HOT 2
- Multi-string support HOT 7
- Nightly artifact build HOT 2
- Plan for existing DSC 1.1 LCM users to migrate to DSC 3.0
- Publish WinGet package HOT 1
- Offline image configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsc.