Adapt script to 'deployment.type'
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Danny Bessems 2021-01-27 20:15:52 +01:00
parent d164f07fb4
commit a66fb18f94
3 changed files with 20 additions and 2 deletions

View File

@ -7,7 +7,7 @@ Param(
# Only executed on secondary or standalone Domain Controller
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
$GetContentSplat = @{
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".$($Parameter['deployment.type']).yml")
Raw = $True
}
$RawContent = Get-Content @GetContentSplat
@ -20,7 +20,7 @@ If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
# Check if the respective .yml file declared substitutions which need to be parsed
If (($YamlDocuments.Count -gt 1) -and $YamlDocuments[-1].Variables) {
ForEach ($Pattern in $YamlDocuments[-1].Variables) {
$RawContent = $RawContent -replace "\{\{ ($($Pattern.Name)) \}\}", [string](Invoke-Expression -Command $Pattern.Expression)
$RawContent = $RawContent -replace "\{\{ ($($Pattern.Name)) \}\}", [string](Invoke-Expression -Command $Pattern.Expression -ErrorAction 'SilentlyContinue')
}
# Perform conversion to Yaml again, now with parsed file contents
$ConvertFromYamlSplat = @{

View File

@ -0,0 +1,18 @@
Entries:
- Name: ldap
Type: A
Value: "{{ primarydc }}"
- Name: timeserver
Type: A
Value: "{{ primarydc }}"
# - Name: mail
# Type: MX
# Value: mail.contoso.com:10 # Value should match pattern '<fqdn>:<preference>'
# - Name: voipserver
# Type: SRV
# Value: sip.contoso.com:0:0:5060 # Value should match pattern '<fqdn>:<priority>:<weight>:<port>'
---
Variables:
- Name: primarydc
Expression: |
(Resolve-DnsName -Name $Parameter['addsconfig.domainname'] | Sort-Object)[0].IPAddress