Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node environment is not determined #161

Open
JonasCassier opened this issue Nov 21, 2023 · 4 comments
Open

Node environment is not determined #161

JonasCassier opened this issue Nov 21, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@JonasCassier
Copy link

JonasCassier commented Nov 21, 2023

Problem description

The expression [x={ $File.Directory.BaseName } =] does not determine node environment.

Verbose logs

null

How to reproduce

# source/AllNodes/Stage/server1.yml
NodeName: '[x={ $Node.Name }=]'
Environment: '[x={ $File.Directory.BaseName } =]'
Role: Webserver
Description: '[x= "$($Node.Role) in $($Node.Environment)" =]'
Location: DataCenter

Expected behavior

ParentFolderName of node yml file is set as node environment.

Current behavior

Describing Node Definition Files
 Context Testing for conflicts / duplicate data
   [+] Should not have duplicate node names 10ms (2ms|8ms)
  [+] 'server1.dev.de' has valid yaml 24ms (21ms|3ms)
  [!] 'server1.dev.de' is in the right environment is skipped, because Environment for 'server1.dev.de' is either not set or like '[x=*' 32ms (29ms|3ms)
  [+] Location of 'server1.dev.de' is 'DataCenter' and does exist 8ms (6ms|1ms)
  [!] Environment of 'server1.dev.de' is '[x={ $File.Directory.BaseName } =]' and does exist is skipped, because Environment for 'server1.dev.de' is either not set or like '[x=*' 5ms (4ms|1ms)
  [+] Role of 'server1.dev.de' is 'Webserver' and does exist 15ms (7ms|8ms)
  [!] Baseline of 'server1.dev.de' is '' and does exist is skipped, because Baseline for 'server1.dev.de' is not set 5ms (4ms|1ms) 

Suggested solution

null

Operating system the target node is running

OsName               : Microsoft Windows 10 Enterprise        
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.19041.3693
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3693
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module version used

null
@raandree raandree self-assigned this Nov 21, 2023
@raandree raandree added the question Further information is requested label Nov 21, 2023
@raandree
Copy link
Contributor

What I see in the logs is an expected warning. Datum handlers are called after tests. How does the RSOP for this node looks like? Does the correct environment show up in the RSOP file? The datum handlers are called in the RSOP task.

@JonasCassier
Copy link
Author

The correct environment show up in the RSOP file. But Description: '[x= "$($Node.Role) in $($Node.Environment)" =]' becomes 'Description: server1.dev.de in '. The value of $Node.Environment is missing.

@JonasCassier
Copy link
Author

If i use no datum expression like Environment: 'Prod' in node yml file the test fails:

[-] Environment of 'Server1.dev.de' is 'Prod' and does exist 19ms (18ms|1ms)
at $node.Environment -in $Environments | Should -BeTrue, C:\Users\Admin\Documents\Code\DSC Workshop\tests\ConfigData\ConfigData.Tests.ps1:165
at , C:\Users\Admin\Documents\Code\DSC Workshop\tests\ConfigData\ConfigData.Tests.ps1:165
Expected $true, but got $false.

@raandree raandree added bug Something isn't working and removed question Further information is requested labels Nov 23, 2023
@raandree
Copy link
Contributor

I see the issue but I am not sure why it happens. There was a problem with calculated values being used in other calculated values but I don't remember the details.

Interestingly, this works which uses two layers of calculated values for the description.

NodeName: '[x={ $Node.Name }=]'
Environment: '[x={ $File.Directory.BaseName } =]'
Role: FileServer
Description: '[x= "$($Node.Role) in $($Node.Var3)" =]'
Location: Frankfurt
Baseline: Server
Var1: fixedValue
Var2: '[x={ "dynamicValue" }=]'
Var3: '[x={ "$($Node.Var1) $($Node.Var2)" }=]'

I will debug this. For now, please assign a static value to the environment

Environment: Dev #'[x={ $File.Directory.BaseName } =]'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants