Configuration and Hash tables and publishing

This topic contains 7 replies, has 2 voices, and was last updated by  Michael Purcaro 1 week, 6 days ago.

  • Author
    Posts
  • #79172

    Michael Purcaro
    Participant

    Hello, All and thanks for your help

    I have a Pull Server setup running WMF 5.1. I am using partial configurations that install IIS and setup 3 websites on a DEV server. Some of the partial configurations use hash tables for the data like the website files to download from the pullserver and the names of the websites that are created. This is all working fine. But I know have a need to create a QA server and I would like to use the same partial configurations which on the ones that use the hash table it creates another mof file. My question is how can I publish the two MOF files on the PullServer using configuration name. Example I have a partial configuration called IntranetMgmt_files.MOF which was renamed from the servername.MOF this works fine for with only one server. But when you add more servers it creates more servername.MOF files. If I tried to name the MOF to any other then ConfigurationName.mof. I receive the error:
    Executing Get-Action on partial configuration xxxxxxxxxxx Failed. Please ensure the partial configuration and its checksum exist on the server. Check the DSC event logs for further details. Which tells me that I can only name it configurationname.mof. Microsoft says I can name it ..mof but this does not seem to work also

  • #79261

    Don Jones
    Keymaster

    You can indeed name a MOF whatever you want, provided there is a matching checksum of the same name, and provided your nodes' LCMs are configured to pull that configuration name. You can't just rename the MOF; the nodes need to be told which MOF to pull.

  • #79289

    Michael Purcaro
    Participant

    Thanks Don
    The following works fine no problems for a Single server in the Hastable

    Configuration IntranetMgmt_files {

    Import-DSCResource -ModuleName PSDesiredStateConfiguration
    Import-DSCResource -ModuleName xPSDesiredStateConfiguration
    Import-DSCResource -ModuleName cRemoteFile

    Node $AllNodes.NodeName {

    Commands to process......

    }
    }

    QA_IntranetMgmt_files -ConfigurationData D:\DSC\Create_MOF_Scripts\SysDev\Intranet-Mgmt\HashTables\IntranetMgmt_Files.psd1 -OutputPath D:\DSC\MOF_Files\IntranetMgmt_files.MOF
    pause
    # QA Confgiuration
    $source = "D:\DSC\MOF_Files\IntranetMgmt_files.MOF\FQDN.MOF"
    $dest = "D:\Program Files\WindowsPowerShell\DscService\Configuration\IntranetMgmt_files.MOf"
    Copy-Item -Path $source -Destination $dest -Force
    New-DSCChecksum $dest -Force

    But, if I add another server in the hastable it creates two MOF files example DEV1.MOF and QA1.MOF.

    If I run the following to copy the MOF's and create new Checksuns on the DSC pull server (I do update the LCM on the target nodes with the new names)

    $source = "D:\DSC\MOF_Files\IntranetMgmt_files.MOF\DEV.MOF"
    $dest = "D:\Program Files\WindowsPowerShell\DscService\Configuration\DEV_IntranetMgmt_files.MOf"
    Copy-Item -Path $source -Destination $dest -Force
    New-DSCChecksum $dest -Force

    $source = "D:\DSC\MOF_Files\IntranetMgmt_files.MOF\DEV.MOF"
    $dest = "D:\Program Files\WindowsPowerShell\DscService\Configuration\QA_IntranetMgmt_files.QA1.MOf"
    Copy-Item -Path $source -Destination $dest -Force
    New-DSCChecksum $dest -Force

    I receive the following error when I run Update-DscConfiguration
    The partial configuration name IntranetMgmt_files present in the configuration document is invalid. Define a partial configuration inside the metaconfiguration with this partial configuration name in
    order to use it.
    + CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 6
    + PSComputerName : DEV1

    If I rename the Title from Configuration IntranetMgmt_files { to Configuration DEV_IntranetMgmt_files {

    and rerun the script it will work fine for DEV1 but I still have a problem with QA1

    So what I am seeing is the TITLE of the confgiuration must match the MOF file name.

  • #79312

    Don Jones
    Keymaster

    You're conflating a few different things.

    Producing a MOF per server is the expected outcome. The reason you use different configuration data blocks is because you have different configuration items for each server, ergo, you need a MOF for each. If that's not the case, then don't use a different configuration block – just produce the one MOF you need.

    The error is telling you that your LCMs are not configured to use the partial configuration. You haven't shared your LCM configuration, but if you can, then I can perhaps offer additional explanation.

  • #79370

    Michael Purcaro
    Participant

    Thanks
    Correct I need to use a hashtable because I need to create websites on two servers and the websites names are same but they end with DEV one server and QA on the other. It creates the two MOF files without any problems; the problem comes when trying to publish the MOF files to the Pull Server, The name must match the title of the Configuration or I receive the error. The below LCM script works fine.

    [DSCLocalConfigurationManager()]
    Configuration HTTPSPULL_LCM_IntranetMgmt_Reports
    {
    param
    (
    [Parameter(Mandatory=$true)]
    [string[]]$ComputerName
    )
    Node $ComputerName {
    Settings {
    RefreshMode = 'Pull'
    Debugmode = "All"
    AllowModuleOverwrite = $True
    ConfigurationMode = 'ApplyAndAutoCorrect'
    CertificateID = 'xxxxxxx'
    ConfigurationModeFrequencyMins = 240
    RefreshFrequencyMins = 1440
    }

    ConfigurationRepositoryWeb DSCPullServer {
    ServerURL = 'https://psdscpullserver.Local:443/PSDSCPullServer.svc/'
    RegistrationKey = “xxxxxxxxxxxxx”
    ConfigurationNames = @("IIS85_Windows2012R2","DotNet35"," IntranetMgmt_AppPool"," IntranetMgmt_files","IntranetMgmt_ODBC","IntranetMgmt_WebSite_dsintranet","IntranetMgmt_WebSite_dsCMS"," IntranetMgmt_WebSite_mgtrptg")
    }

    PartialConfiguration IIS85_Windows2012R2 {
    Description = 'Installs IIS 8.5 on Windows 2012 R2 with WellsFargo Confgiuration Standards'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    }

    PartialConfiguration DotNet35 {
    Description = 'Installs DotNet 3.5'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration]IIS85_Windows2012R2'
    }

    PartialConfiguration IntranetMgmt_AppPool {
    Description = 'Sets up the Applocation Pool'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration]IIS85_Windows2012R2'
    }

    PartialConfiguration IntranetMgmt_files {
    Description = 'Downloads Website files and extracts'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration]DotNet35'
    }

    PartialConfiguration IntranetMgmt_ODBC {
    Description = 'Sets up the DSNs'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    }

    PartialConfiguration DEV_IntranetMgmt_WebSite_dsintranet {
    Description = 'Setup website dsintranet'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration] IntranetMgmt_files'
    }

    PartialConfiguration IntranetMgmt_WebSite_dsCMS {
    Description = 'Setup website dsCMS'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration] IntranetMgmt_files'
    }

    PartialConfiguration IntranetMgmt_WebSite_mgtrptg {
    Description = 'Setup website mgtrptg'
    ConfigurationSource = @("[ConfigurationRepositoryWeb]DSCPullServer")
    DependsOn = '[PartialConfiguration] IntranetMgmt_files'
    }

    ReportServerWeb PSDSCReportServer {
    ServerURL = 'https://psdscpullserver.Local:443/PSDSCPullServer.svc/'
    }
    }
    }

  • #79373

    Don Jones
    Keymaster

    AH. I totally did not get all that.

    So you NEED two different MOFs. Ergo, they need to have different names. You can't have both nodes configured to pull the same MOF. You know this, I'm sure.

    So now that I've got the picture, let's circle back. You have the pull server. It has two MOFs, with different names. Each node is configured to pull the correct MOF for itself. The configuration name is the same as the MOF filename.

    But you're still getting an error from one (both?) nodes.

    I got all that?

    The problem you can run into is that, when you produce the MOF, the "name" of the configuration gets embedded inside it. If that doesn't match what the node expects, it all blows up. You can't just copy one MOF; you have to produce two to begin with.

  • #79430

    Michael Purcaro
    Participant

    Yes the script creates two MOF files. Say Dev1.mof and QA1.MOF both MOF files have the configuration “IntranetMgmt_files” embedded which is the problem.

    The below commands is how I have been publishing to the Pull server
    # Dev Configuration
    $source = "D:\DSC\MOF_Files\IntranetMgmt_files.MOF\ Dev1.mof "
    $dest = "D:\Program Files\WindowsPowerShell\DscService\Configuration\ IntranetMgmt_files.MOf"
    Copy-Item -Path $source -Destination $dest -Force
    New-DSCChecksum $dest –Force

    This all works fine because the MOF file name matches the Configuration Title and works fine for a single server but if you have a Hashtable with more than one server you cannot publish them both on the Pull server because the embedded name.

    So the only way round this so far is to create two Configuration scripts with the title DEV_ IntranetMgmt_files and QA_ IntranetMgmt_files and two hashtables.
    I believe this is defeating the purpose of using the Hashtables. It should create a single MOF file with all the node names and the configuration data in it so you can publish it on the Pull Server with a single name using a single hashtable that has 2 or more node configurations

    Microsoft has the this document
    https://docs.microsoft.com/en-us/powershell/dsc/partialconfigs
    That states:
    Naming and placing the configuration documents on the pull server (ConfigurationNames)

    The partial configuration documents must be placed in the folder specified as the ConfigurationPath in the web.config file for the pull server (typically C:\Program Files\WindowsPowerShell\DscService\Configuration).

    Naming configuration documents on the pull server in PowerShell 5.1

    If you are pulling only one partial configuration from an individual pull server, the configuration document can have any name. If you are pulling more than one partial configuration from a pull server, the configuration document can be named either .mof, where ConfigurationName is the name of the partial configuration, or ..mof, where ConfigurationName is the name of the partial configuration, and NodeName is the name of the target node. This allows you to pull configurations from Azure Automation DSC pull server.
    I tried to use ..mof and it did not work, But based on how its worded I not sure if this is supposed to work on a standalone Pull Server or is only for Azure.

  • #79432

    Michael Purcaro
    Participant

    The from must not like some chars,
    Microsoft has the this document
    https://docs.microsoft.com/en-us/powershell/dsc/partialconfigs
    That states:
    Naming and placing the configuration documents on the pull server (ConfigurationNames)

    The partial configuration documents must be placed in the folder specified as the ConfigurationPath in the web.config file for the pull server (typically C:\Program Files\WindowsPowerShell\DscService\Configuration).

    Naming configuration documents on the pull server in PowerShell 5.1

    If you are pulling only one partial configuration from an individual pull server, the configuration document can have any name. If you are pulling more than one partial configuration from a pull server, the configuration document can be named either “ConfigurationName.mof”, where ConfigurationName is the name of the partial configuration, or “ConfigurationName.NodeName.mof”, where ConfigurationName is the name of the partial configuration, and NodeName is the name of the target node. This allows you to pull configurations from Azure Automation DSC pull server.
    I tried to use “ConfigurationName.NodeName.mof” and it did not work, But based on how its worded I not sure if this is supposed to work on a standalone Pull Server or is only for Azure.

You must be logged in to reply to this topic.