I’m working on a configuration that will be used to build out ColdFusion servers. Each server will have a variable number of server instances running in its cluster and for each server there is a service created in Windows. First a Script Resource runs that builds out the ColdFusion servers (the services are built as part of this script). Then, I’m trying to set the services in my configuration using a ForEach that loops through an array of service names I pass into the config data. Is this possible? I’m getting a “Unexpected token ‘}’ in expression or statement.” in my syntax after the Service resource.
Here is the PSD1 file:
@{ AllNodes = @( @{ NodeName = "*" NeoConfigDestinationPath = "D:\ServerBox\Servers\JRun4\_build\shared\config" } @{ NodeName = 'PullServerName' Role=@('DSCPullServer') } @{ NodeName = 'DevIntTest' Role=@('IIS','ServerBox','DevInt') CFServices=@("Adobe CF9 1","Adobe CF9 2","Adobe CF9 3") } @{ NodeName = 'AlphaTest' Role=@('IIS','ServerBox','Alpha') CFServices=@("Adobe CF9 1") } ) ServerBoxConfig = @{ SourcePath = "\\SHARE\PATH\DevOps\ServerBox" DestinationPath = "D:\ServerBox" NeoConfigSourcePath = "\\SHARE\PATH\DevOps\ServerConfig\Environments\_Default\NeoConfig" } DevIntConfig = @{ SourcePath = "\\SHARE\PATH\DevOps\DevInt" DestinationPath = "D:\ServerBox\IIS\wwwroot" NeoConfigSourcePath = "\\SHARE\PATH\DevOps\ServerConfig\Environments\DevInt\NeoConfig" } AlphaConfig = @{ SourcePath = "\\SHARE\PATH\DevOps\Alpha" DestinationPath = "D:\ServerBox\IIS\wwwroot" NeoConfigSourcePath = "\\SHARE\PATH\DevOps\ServerConfig\Environments\Alpha\NeoConfig" } }
And then here is the configuration I’m working up:
Configuration EqConfig { Import-DSCResource -Module xPSDesiredStateConfiguration Node $AllNodes.Where({$_.role -eq 'DSCPullServer'}).NodeName {...} #DSCPullServer Node $AllNodes.Where({$_.role -eq 'IIS'}).NodeName {...} #IIS Node $AllNodes.Where({$_.role -eq 'ServerBox'}).NodeName { File ServerBox { Ensure = "Present" Type = "Directory" Recurse = $true MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.ServerBoxConfig.SourcePath DestinationPath = $ConfigurationData.ServerBoxConfig.DestinationPath } File ServerBox_Default_Config { Ensure = "Present" Type = "Directory" MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.ServerBoxConfig.NeoConfigSourcePath DestinationPath = $AllNodes.NeoConfigDestinationPath DependsOn = "[File]ServerBox" } } #ServerBox Node $AllNodes.Where({$_.role -eq 'DevInt'}).NodeName { File DevInt { Ensure = "Present" Type = "Directory" Recurse = $true MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.DevIntConfig.SourcePath DestinationPath = $ConfigurationData.DevIntConfig.DestinationPath DependsOn = "[File]ServerBox" } File DevInt_Config { Ensure = "Present" Type = "Directory" MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.DevIntConfig.NeoConfigSourcePath DestinationPath = $AllNodes.NeoConfigDestinationPath DependsOn = "[File]ServerBox" } Script createDevIntServers { SetScript = "Create-ColdfusionServer -clusterCount $Node.CFServices.Length" TestScript = "" GetScript = "" } Service $Node.CFServices.ForEach({ Name = $_ State = 'Running' DependsOn = "[Script]createDevIntServers" }) } #DevInt Node $AllNodes.Where({$_.role -eq 'Alpha'}).NodeName { File Alpha { Ensure = "Present" Type = "Directory" Recurse = $true MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.AlphaConfig.SourcePath DestinationPath = $ConfigurationData.AlphaConfig.DestinationPath DependsOn = "[File]ServerBox" } File Alpha_Config { Ensure = "Present" Type = "Directory" MatchSource = $true Force = $true Checksum = "modifiedDate" SourcePath = $ConfigurationData.AlphaConfig.NeoConfigSourcePath DestinationPath = $AllNodes.NeoConfigDestinationPath DependsOn = "[File]ServerBox" } Script createAlphaServers { SetScript = "Create-ColdfusionServer -clusterCount $Node.CFServices.Length" TestScript = "" GetScript = "" } Service $Node.CFServices.ForEach({ Name = $_ State = 'Running' DependsOn = "[Script]createAlphaServers" }) } #Alpha } #Configuration