dsccommunity / DscWorkshop

Blueprint for a full featured DSC project for Push / Pull with or without CI/CD
MIT License
203 stars 162 forks source link

Override $Datum.Global. #168

Closed dan-hughes closed 7 months ago

dan-hughes commented 7 months ago

Hi,

Is there a way of overriding the $Datum.Global settings per environment for example?

raandree commented 7 months ago

Yes, have a look at the Azure.yml of the Microsoft365DscWorkshop.

Accessing the value works like this: $datum.Global.Azure.Environments.Dev.AzTenantId

raandree commented 7 months ago

I got an email notification about this comment you have added here yesterday, not sure why it disappeared.


I'm not sure if this is the intended way, but I managed to resolve it by adding the following to my Environment\Dev.yml: Domain: DomainFqdn: dev.contoso.com DomainDn: dc=dev,dc=contoso,dc=com Then using DomainName: '[x={ "$($Datum.Environment.$($Node.Environment).Domain.DomainFqdn)" }=]' in the DomainController.yml role file. It works, just feels a little dirty.


Your suggestion is correct and you can use the Datum.InvokeCommand handler to define dynamic variable access. This approach is not really aligned with the idea behind datum but gives you a new way of flexibility and scale.

dan-hughes commented 7 months ago

I've just looked through the Microsoft365DSCWorkshop and it was not what I was looking for, but looking further I did find my answer to my own question in another file. The interpolation in this case needs to be like this $Datum.Environments."$($Node.Environment)".Domain.DomainFqdn. The deleted comment was me thinking I had a breakthrough, but after my manual testing I closed and re-opened the terminal and it didn't work.

Thanks for the response.

raandree commented 7 months ago

You are welcome. I am closing this issue. Please get back to us if you have further questions.