Hi There,
I’m working on a DSC definition for an IIS setup where I have a PSD1 file with the variables and another file with the DesiredState Configuration, as shown below:
psd1 file
@{
AllNodes = @(
@{
NodeName = 'localhost'
...
Folders = @(
@{
id = 'SiteAFolder'
state = 'present'
phy_path = 'c:\wwwroot\SiteAFolder'
}
@{
id = 'SiteBFolder'
state = 'present'
phy_path = 'c:\wwwroot\SiteBFolder'
}
)
WebAppPools = @(
@{
id = 'SiteAPool'
ensure = 'present'
state = 'started'
name = 'SiteAPool'
DependsOn = 'SiteAFolder'
}
@{
id = 'SiteBPool'
ensure = 'present'
state = 'started'
name = 'SiteBPool'
DependsOn = 'SiteBFolder'
}
)
WebSites = @(
@{
id = 'SiteA'
ensure = 'present'
state = 'started'
name = 'www.siteA.com'
WebAppPool = 'SiteAPool'
Folder = 'SiteAFolder''
HTTP_Port = '80'
HTTPS_Port = '443'
SSL_Thumb = '...'
SSL_Store = 'WebHosting'
}
@{
id = 'SiteB'
ensure = 'present'
state = 'started'
name = 'www.siteB.com'
WebAppPool = 'SiteBPool'
Folder = 'SiteBFolder''
HTTP_Port = '80'
HTTPS_Port = '443'
SSL_Thumb = '...'
SSL_Store = 'WebHosting'
}
)
DSC file
# Configure Sites
Configuration SiteConfiguration {
Import-DscResource –ModuleName 'PSDesiredStateConfiguration', 'xWebAdministration'
node $AllNodes.NodeName {
...
$Node.Folders.ForEach({
File $_.id {
Ensure = "Present"
Type = 'Directory'
DestinationPath = $_.phy_path
}
})
$Node.WebAppPools.ForEach({
xWebAppPool $_.id {
Ensure = $_.ensure
State = $_.state
Name = $_.name
DependsOn = '[File]' + $_.DependsOn
}
})
$Node.WebSites.ForEach({
xWebsite $_.id {
Ensure = $_.ensure
State = $_.state
Name = $_.name
ApplicationPool = '[xWebAppPool]' + $_.WebAppPool
PhysicalPath = '[Folder]' + $_.folder
...
The point is… everything seems to work fine, however after the definitions are applied I noticed that the ApplicationPool
and PhysicalPath
variables for xWebsite aren’t being resolved to the respective expected configs. On IIS configuration, the former is set to '[xWebAppPool]'SiteAPool
and '[Folder]'SiteAFolder
, rather than SiteAPool
and c:\wwwroot\SiteAFolder
, respectively.
It seems that DSC is not capable to resolve the variables based on IDs. When I set the names directly, instead of variables, it works as expected.
Does anyone has seen this before and can give a clue how to make this work using variables?
Thanks in advance,