dsccommunity / FailoverClusterDsc

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

Compilation completed successfully, but no node configuration .mofs were generated #182

Closed cdeli closed 6 years ago

cdeli commented 6 years ago

I have no idea what is even going on at this point. I have done everything to make this work but apparently nodename is not accepted. I am running version 1.10.0.0 of xFailOverCluster in Azure Automation and no matter what I do I get the error in the title.

$ConfigurationData = @{
    AllNodes = @(
        @{
            NodeName                    = '*'
            ClusterName                 = 'Cluster01'
            ClusterIPAddress            = '10.1.1.8/24'
        },

        # Node01 - First cluster node.
        @{
            # Replace with the name of the actual target node.
            NodeName = 'Contoso-SVR-000000'

            # This is used in the configuration to know which resource to compile.
            Role     = 'FirstServerNode'
        },

        # Node02 - Second cluster node
        @{
            # Replace with the name of the actual target node.
            NodeName = '*'

            # This is used in the configuration to know which resource to compile.
            Role     = 'AdditionalServerNode'
        }
    )
}

Configuration rdshNew
{

    param (

        #$NodeName = 'localhost',

        [Parameter(Mandatory = $true)]
        [ValidateNotNullorEmpty()]
        [System.Management.Automation.PSCredential]
        $Creds
    )

    $DomainName = 'Contoso.pri'

Import-DscResource -ModuleName PsDscResources
Import-DscResource -ModuleName ComputerManagementDSC
Import-DscResource -ModuleName xFailoverCluster
Import-DscResource -ModuleName xRemoteDesktopSessionHost

    Node $AllNodes.Where{$_.Role -eq 'FirstServerNode' }
    {
        WindowsFeature Remote-Desktop-Services
        {
            Ensure = "Present"
            Name = "Remote-Desktop-Services"
        }
        WindowsFeature RDS-RD-Server
        {
            Ensure = "Present"
            Name = "RDS-RD-Server"
            DependsOn = "[WindowsFeature]Remote-Desktop-Services"
        }
        WindowsFeature FC
        {
            Name = "Failover-Clustering"
            Ensure = "Present"
            DependsOn = "[WindowsFeature]RDS-RD-Server"
        }

        WindowsFeature AddRemoteServerAdministrationToolsClusteringCmdInterfaceFeature
        {
            Ensure    = 'Present'
            Name      = 'RSAT-Clustering-CmdInterface'
            DependsOn = '[WindowsFeature]FC'
        }

        WindowsFeature FCPS
        {
            Name = "RSAT-Clustering-PowerShell"
            Ensure = "Present"
            DependsOn = "[WindowsFeature]AddRemoteServerAdministrationToolsClusteringCmdInterfaceFeature"
        }

        WindowsFeature ADPS
        {
            Name = "RSAT-AD-PowerShell"
            Ensure = "Present"
            DependsOn = "[WindowsFeature]FCPS"
        }

        WindowsFeature FS
        {
            Name = "FS-FileServer"
            Ensure = "Present"
            DependsOn = "[WindowsFeature]ADPS"
        }

        Computer JoinDomain
        {
            Name       = $NodeName
            DomainName = $DomainName
            Credential = $Creds
            JoinOU = "OU=Servers,OU=TestGroup,DC=Contoso,DC=PRI"
            DependsOn = "[WindowsFeature]FS"
        }

        xCluster FailoverCluster
        {
            Name = $Node.ClusterName
            StaticIPAddress = $Node.ClusterIPAddress
            DomainAdministratorCredential = $Creds
            DependsOn = "[Computer]JoinDomain"
        }

        Node $AllNodes.Where{ $_.Role -eq 'AdditionalServerNode' -and $_.NodeName -ne 'Contoso-SVR-000000' }
        {
            WindowsFeature AddFailoverFeature
            {
                Ensure = 'Present'
                Name   = 'Failover-clustering'
            }

            WindowsFeature AddRemoteServerAdministrationToolsClusteringPowerShellFeature
            {
                Ensure    = 'Present'
                Name      = 'RSAT-Clustering-PowerShell'
                DependsOn = '[WindowsFeature]AddFailoverFeature'
            }

            WindowsFeature AddRemoteServerAdministrationToolsClusteringCmdInterfaceFeature
            {
                Ensure    = 'Present'
                Name      = 'RSAT-Clustering-CmdInterface'
                DependsOn = '[WindowsFeature]AddRemoteServerAdministrationToolsClusteringPowerShellFeature'
            }

            Computer JoinDomain
            {
                Name       = $NodeName
                DomainName = $DomainName
                Credential = $Creds
                JoinOU = "OU=Servers,OU=TestGroup,DC=Contoso,DC=PRI"
                DependsOn = "[WindowsFeature]AddRemoteServerAdministrationToolsClusteringCmdInterfaceFeature"
            }

            xWaitForCluster WaitForCluster
            {
                Name             = $Node.ClusterName
                RetryIntervalSec = 10
                RetryCount       = 60
                DependsOn        = '[WindowsFeature]JoinDomain'
            }

            xCluster JoinSecondNodeToCluster
            {
                Name                          = $Node.ClusterName
                StaticIPAddress               = $Node.ClusterIPAddress
                DomainAdministratorCredential = $ActiveDirectoryAdministratorCredential
                DependsOn                     = '[xWaitForCluster]WaitForCluster'
            }
        }
    }
}
johlju commented 6 years ago

Should it be Node $AllNodes.Where{$_.Role -eq 'FirstServerNode' }.NodeName? :thinking: I haven’t tested it as I don’t have access to a computer now.

cdeli commented 6 years ago

I attempted it with that. It does not get that far it seems. No matter how I have that set up, I get this error as the node names are responding as $null apparently. I have no idea why.

johlju commented 6 years ago

You have two NodeName = ‘*’, if you remove one, is it still the same problem? How do you execute the configuration “rdshnew”?

cdeli commented 6 years ago

I fixed that nodename in my code, that was an oversight when i was reverting back to the first.

Right from Azure Automation DSC GUI. I can't get it to compile though without getting that error which tends to lead to $nodename being $null.

johlju commented 6 years ago

When using a configuration data block you need to user PowerShell to compile it in Azure Automation. Look at AzureRm cmdlet for compiling a configuration (don’t remember the actually name of the cmdlet now).

cdeli commented 6 years ago

So I should remove it from the DSC file and run it separate against the compiled file "rdshNew"?

johlju commented 6 years ago

You should pass the $ConfigurationData in the parameter ConfigurationData. See https://docs.microsoft.com/en-us/azure/automation/automation-dsc-compile

cdeli commented 6 years ago

It does not matter. No matter what I do I am getting the same error. This is an issue with it not accepting a wildcard as NodeName it seems.

cdeli commented 6 years ago

Even without any config data in the DSC file, I am getting the exact same error.

cdeli commented 6 years ago

Ok after using an article I found how to get that error resolved. I am now running into this error

"The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: An exception was raised while processing Node 'Master': Defining node 'Additional' inside the current node 'Master' is not allowed since node definitions cannot be nested. Please move the definition for node 'Additional' to the top level of the configuration 'rdshNew'. At line:84 char:5 + Node"

Now I understand what this error means, however, as you can see in the code above, these are seperate Node calls, they are not nested. My config data looks as follows:


$Parameters = @{
    'Creds' = "Creds"
}

$ConfigData =
@{
    AllNodes =
    @(
        @{
            NodeName                    = '*'
            ClusterName                 = 'Cluster01'
            ClusterIPAddress            = '<IP>'
            PSDscAllowPlainTextPassword = $true
        },

        @{
            NodeName = "Master"
            Role     = "FirstServerNode"
        },

        @{
            NodeName = "Additional"
            Role     = "AdditionalServerNode"
        }
    )
}

Not sure why it believes this is nested when it is not at all.

johlju commented 6 years ago

Ah I see now in your initial code in the issue description that you had one node block nested. The line ‘Node $AllNodes.Where{ $.Role -eq 'AdditionalServerNode' -and $.NodeName -ne 'Contoso-SVR-000000' }’. I did not look so far in the code to be honest. :/

Tommy-Ten commented 4 years ago

I'm having exactly the same issue. @cdeli did you solve the problem by any chance?