dsccommunity / FailoverClusterDsc

This module contains DSC resources for deployment and configuration of Windows Server Failover Cluster.
MIT License
60 stars 54 forks source link

Cluster: Cluster created with path CN= is not idempotent #195

Open jdwhited opened 6 years ago

jdwhited commented 6 years ago

Details of the scenario you tried and the problem that is occurring

I created a cluster with a custom path for the CNO. Example:

Name = CN=mycluster,OU=ClusterOU,OU=Main,DC=example,DC=com

This actually worked great, but it is not idempotent. Even though the New-Cluster that the DSC calls allows for a custom path /name, the DSC doesn't expect that when calling the Test.

Verbose logs showing the problem

Error Message: PowerShell DSC resource MSFT_xCluster failed to execute Set-TargetResource functionality with error message: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: There was an error adding node 'myserver' to the cluster The computer 'myserver.example.com' is joined to a cluster

Suggested solution to the issue

There are multiple ways to handle this (including adding a path parameter), but from a coding perspective the easiest is to just check the $Name for a CN= prefix and pull out the actual cluster name. If there is no CN= prefix just use the name with the original intent:

       if ( $Name -match '^CN=' ) {
          $CN = $Name.split('{,}')
          $Name = $CN[0].split('{=}')[1]
        }

The DSC configuration that is used to reproduce the issue (as detailed as possible)

Configuration Example
{
    param(
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $ActiveDirectoryAdministratorCredential
    )

    Import-DscResource -ModuleName xFailOverCluster

    Node localhost
    {

        xCluster CreateCluster
        {
            Name                          = 'CN=mycluster,OU=ClusterOU,OU=Main,DC=example,DC=com'
            StaticIPAddress               = '10.10.10.1'

            <#
                This user must have the permission to create the CNO (Cluster Name Object) in Active Directory,
                unless it is prestaged.
            #>
            DomainAdministratorCredential = $ActiveDirectoryAdministratorCredential

        }
    }
}

The operating system the target node is running

OsName : Microsoft Windows Server 2012 R2 Standard OsOperatingSystemSKU : StandardServerEdition OsArchitecture : 64-bit WindowsBuildLabEx : 9600.19153.amd64fre.winblue_ltsb.180908-0600 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.14409.1012
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1012
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

dev

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

jdwhited commented 5 years ago

Thoughts?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity from the community in the last 30 days. It will be closed if no further activity occurs within 10 days. If the issue is labelled with any of the work labels (e.g bug, enhancement, documentation, or tests) then the issue will not auto-close.

jdwhited commented 5 years ago

I don't think I can label this, correct?

johlju commented 5 years ago

@jdwhited Sorry for not labeling this before this, I have been busy with the day job. But starting to get some time to focus on issues and reviewing PR's now.

johlju commented 5 years ago

@jdwhited It would be great to add an example file for this change as well when this issue is resolved.