Partial Configuration Bug - module imported twice error

This topic contains 12 replies, has 4 voices, and was last updated by  Olli Janatuinen 1 year, 10 months ago.

  • Author
    Posts
  • #29449

    Zuldan
    Participant

    I've started testing WMF 5 Production Preview against my DSC config that works perfectly with WMF 5 April Preview. To cut a long story short I can no longer apply partial DSC config to a node. Any one of the following errors can appear:

    The resource PSDesiredStateConfiguration from module MSFT_FileDirectoryConfiguration is imported twice using
    version 1.0 and version 0.0. Using more than one version of a resource is not supported. Remove one of the
    versions to correct the problem.

    The resource PSDesiredStateConfiguration from module MSFT_RoleResource is imported twice using version 0.0 and version 1.0. Using more than one version of a resource is not supported. Remove one of the versions to correct the problem.

    The resource PSDesiredStateConfiguration from module MSFT_ScriptResource is imported twice using version 0.0 and version 1.0. Using more than one
    version of a resource is not supported. Remove one of the versions to correct the problem.

    I've created some proof of concept code to show how the error can be generated.

    ——— LCMConfig.ps1 snip ————-

    [DSCLocalConfigurationManager()]
    Configuration LCMConfig
    {
    param
    (
    [Parameter(Mandatory = $True)]
    [string]$ComputerName,

    [Parameter(Mandatory = $True)]
    [string]$PullServer,

    [Parameter(Mandatory = $True)]
    [string]$GUID
    )

    Node $ComputerName {

    Settings {
    RefreshMode = "Pull"
    ConfigurationID = $GUID
    RebootNodeIfNeeded = $True
    }

    ConfigurationRepositoryWeb DSCHTTP {
    ServerURL = "http://$($PullServer):8080/PSDSCPullServer.svc"
    AllowUnsecureConnection = $True
    }

    PartialConfiguration PartConfig1
    {
    Description = 'Test description'
    ConfigurationSource = '[ConfigurationRepositoryWeb]DSCHTTP'
    }

    PartialConfiguration PartConfig2
    {
    Description = 'Test description'
    ConfigurationSource = '[ConfigurationRepositoryWeb]DSCHTTP'
    DependsOn = '[PartialConfiguration]PartConfig1'
    }
    }
    }

    ——— LCMConfig.ps1 snip ————-

    ——— PartConfig.ps1 snip ————-

    configuration PartConfig1
    {
    Import-DscResource –ModuleName PSDesiredStateConfiguration

    node ("PartConfig1.$GUID")
    {
    File FriendlyName1
    {
    Ensure = 'Present'
    DestinationPath = 'C:\PartConfig1.txt'
    Type = 'File'
    }
    }
    }

    configuration PartConfig2
    {
    Import-DscResource –ModuleName PSDesiredStateConfiguration

    node ("PartConfig2.$GUID")
    {
    File FriendlyName2
    {
    Ensure = 'Present'
    DestinationPath = 'C:\PartConfig2.txt'
    Type = 'File'
    }

    Script WDSAnswerPolicy {
    PsDscRunAsCredential = $Credential
    GetScript = {
    @{
    GetScript = $GetScript
    SetScript = $SetScript
    TestScript = $TestScript
    Result = $True
    }
    }

    SetScript = {
    # Do nothing
    }

    TestScript = {
    $True
    }
    }
    }
    }

    ——— PartConfig.ps1 snip ————-

    ——— Run.ps1 snip ————-

    $Node = 'MyTestNode'
    $PullServer = 'MyTestPullServer'
    $GUID = 'b32e5e76-fe9f-4fef-8d58-9ff9d3a268d3'
    $MOFDestPath = 'C:\Program Files\WindowsPowerShell\DscService\Configuration'

    # Import Functions
    . "$PSScriptRoot\LCMConfig.ps1"
    . "$PSScriptRoot\PartConfig.ps1"

    # Generate MOF files
    $MOFFile = PartConfig1 -OutputPath $MOFDestPath
    New-DscChecksum -Path "$MOFDestPath\$MODFile" -Force

    $MOFFile = PartConfig2 -OutputPath $MOFDestPath
    New-DscChecksum -Path "$MOFDestPath\$MODFile" -Force

    # Generate Meta MOF file
    LCMConfig -ComputerName $Node -PullServer $PullServer -GUID $GUID -OutputPath "$PSScriptRoot\Temp"

    # Send Meta MOF config to Node
    Set-DscLocalConfigurationManager -ComputerName $Node -Path "$PSScriptRoot\Temp" -Verbose

    # Update Configuation
    Update-DscConfiguration -ComputerName $Node -Wait -Verbose

    ——— Run.ps1 snip ————-

  • #29450

    Don Jones
    Keymaster

    Have you reported this to Microsoft?

  • #29451

    Zuldan
    Participant

    Hi Don, thanks for the quick response. Not yet, but if someone else can confirm they are seeing the same thing in their environment, I'll post it on Connect.

    This is bug number 3 for me. Hopefully MS can fix the issues before full production is released. This particular bug massive show stopper for me. I haven't come across anyone else having this issue so I'm hoping it's just something weird with my environment and the proof of concept example runs perfectly on someone elses environment.

    Partial Conf Bug 1:
    https://connect.microsoft.com/PowerShell/feedback/details/1624273/dsc-partial-configuration-bug-8-config-limit

    Partial Conf Bug 2:
    https://connect.microsoft.com/PowerShell/feedback/details/1515243/if-rebootnodeifneeded-false-and-a-reboot-is-required-partial-configurations-do-not-complete

  • #29452

    Dave Wyatt
    Moderator

    What's in your two partial configuration MOF files? Do they both reference version 0.0?

    We've seen some stuff going back and forth about this new "0.0" functionality in the MVP mailing list, and Microsoft has said that DSC is supposed to just import the latest available version of a module when it sees that. However, if a module is already loaded and then it errors out (even though it should just be importing the same, latest available version), then this is a bug that they need to fix.

  • #29453

    Zuldan
    Participant

    Dave, you're onto something. The partial config mof files reference different module versions. That has to be bug. Please could you kindly keep us posted on any updates with this from the MVP mailing. It would be much appreciated!

    —–PartConfig1 snip——
    ModuleVersion = "1.0";
    ConfigurationName = "PartConfig1";
    };
    —–PartConfig1 snip——

    —–PartConfig2 snip——
    ModuleVersion = "0.0";
    ConfigurationName = "PartConfig2";
    };
    —–PartConfig2 snip——

  • #29455

    Dave Wyatt
    Moderator

    Hmm, that's odd. You compiled the MOFs from the same computer, but for some reason they produced different versions in the output. I'll send a message to the mailing list referencing this thread, and see what comes up.

  • #29456

    Zuldan
    Participant

    Yeah very strange.

    I modified PartConfig2.mof and changed 0.0 to 1.0, which produced the following error.

    Cannot find module PSDesiredStateConfiguration_1.0 from the server http://s12aumdc01tst01:8080/PSDSCPullServe
    r.svc/Module(ConfigurationId='b32e5e76-fe9f-4fef-8d58-9ff9d3a268d3',ModuleName='PSDesiredStateConfiguration',
    ModuleVersion='1.0')/ModuleContent.
    + CategoryInfo : ResourceUnavailable: (root/Microsoft/...gurationManager:String)

  • #29457

    Dave Wyatt
    Moderator

    Try going the other way; change them both to 0.0.

  • #29458

    Zuldan
    Participant

    Dave, you rock! The DSC configuration continued and the error didn't appear with the example code in the post.

    I then did a "search and replace" on my production (preview) MOF files (83 hits) and changed all occurrences of ModuleVersion = "1.0"; to ModuleVersion = "0.0"; The DSC partial config is now applying to the node. Dirty as hell but hey it's a work around.

    Lets hope Microsoft can fix this ASAP. I'll post the bug up on Connect tomorrow.

  • #29506

    Zuldan
    Participant
  • #29514

    Don Jones
    Keymaster

  • #29516

    Zuldan
    Participant

    Fantastic! Thanks Don. MS are onto it.

  • #31472

    Olli Janatuinen
    Participant

    A workaround to problem is import "PSDesiredStateConfiguration" module with version number on all of partial configs.

    Example on my environment Get-DscResouce told that actually right version number is 1.1 and problem disappeared after I forced version number like this:
    Import-DscResource -ModuleName @{ModuleName="PSDesiredStateConfiguration";ModuleVersion="1.1"}

You must be logged in to reply to this topic.