Multiple Composite DSC using Single Resource

Welcome Forums DSC (Desired State Configuration) Multiple Composite DSC using Single Resource

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #28362

    Participant
    Points: 0
    Rank: Member

    I have several composite DSC resources that make my master configurations super simple. However I just ran into a problem where a composite DSC is using the xGroup resource to add a member to local administrators. I then need to also add another user to administrators as part of the master configuration. This errors because the group name "Administrators" is the key for the xGroup resource.

    Has anyone run into this scenario and how'd you get around it?

    I currently see these as my options and I'm not sure which is best...

    1) Modify xGroup (cGroup) to support what I need by having some other key identifier
    2) Create new DSC resource xLocalAdministrator (based on xGroup) that allows multiple definitions
    3) Remove the xGroup definition from the composite resource and have to put it into my master configurations instead.

    I am currently leaning towards option 2.\

    Example configuration:

    Configuration SoftwarePackageX
    {
        Import-DscResource -Name MSFT_xGroup
        xGroup Administrators
        {
            GroupName = 'Administrators'
            MembersToInclude = 'DOMAIN\SERVICEACCOUNT'
        }
    }
    
    Configuration SqlServer
    {
        Import-DscResource -Name MSFT_xGroup
    
        xGroup Administrators
        {
            GroupName = 'Administrators'
            MembersToInclude = 'DOMAIN\Database Administrators'
        }
    
        SoftwarePackageX {}
    }
  • #28404

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    Well, the problem with 1 and 2 is that the configuration becomes harder to troubleshoot and understand, because you're modifying the same element in multiple places. Given the lack of "RSOP" or anything similar in DSC, the idea is to keep things as atomic as possible to ease other tasks. I'd lean toward number 3 solely to keep things human-easier. Failing that, I suppose #2 is the most technically efficient option.

  • #28457

    Participant
    Points: 0
    Rank: Member

    Using configuration data to populate that is probably the most effective way, putting an Administrators property on my base server composite configuration and passing in the list of users that will need to be added to it as part of that initial configuration should work.

    Thanks Don.

The topic ‘Multiple Composite DSC using Single Resource’ is closed to new replies.