Skip to content

Commit

Permalink
Fixed DNS issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-p committed Apr 9, 2020
1 parent 2960a46 commit 3f0c67a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Works on
| pdc_forest_functional_level | Default ([Windows2008R2](https://github.com/MicrosoftDocs/windows-powershell-docs/blob/master/docset/windows/addsdeployment/Install-ADDSForest.md#-forestmode)) | Specifies the forest functional level for the new forest. The default forest functional level in Windows Server is typically the same as the version you are running. Change this depending on your needs. |
| pdc_required_psmodules | [xPSDesiredStateConfiguration, NetworkingDsc, ComputerManagementDsc, ActiveDirectoryDsc] | PowerShell/DSC modules to install from the PSGallery. Always make sure to include `ActiveDirectoryDsc`for the `WaitForAD`-check. 9/10 times you should leave this to the default value. |
| pdc_required_features | ["AD-domain-services", "DNS"] | Windows Features that should be installed on the Domain Controller. Defaults to AD-domain-services and DNS. 9/10 times you should leave this to the default value. |
| pdc_desired_dns_forwarders | ["8.8.8.8","8.8.4.4"] | The desired DNS Forwarders for the PDC. Defaults to Google DNS. Change this depending on your needs. |

## Dependencies

Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pdc_domain_functional_level: Default
pdc_forest_functional_level: Default
pdc_required_psmodules: [xPSDesiredStateConfiguration, NetworkingDsc, ComputerManagementDsc, ActiveDirectoryDsc]
pdc_required_features: ["AD-domain-services", "DNS"]
pdc_desired_dns_forwarders: ["8.8.8.8","8.8.4.4"]
26 changes: 26 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@
resource_name: WaitForADDomain
DomainName: "{{ pdc_domain }}"

- name: Ensure DNS Forwarders are set to desired forwarders
win_shell: |
Try {
$CurrentForwarders = $([Array]$(Get-DnsServerForwarder).IPAddress.IPAddressToString)
$DesiredForwarders = ConvertFrom-JSON '{{ pdc_desired_dns_forwarders | to_json }}'
if ($Null -ne $(Compare-Object $CurrentForwarders $DesiredForwarders)) {
Set-DNSServerForwarder -IPAddress $DesiredForwarders
Exit 1
} Else {
Exit 0
}
} Catch {
return 2
}
register: dns_forwarders
changed_when: dns_forwarders.rc == 1
failed_when: dns_forwarders.rc == 2
become: yes
become_user: "{{ ansible_user }}"
become_method: runas

- name: Ensure upstream DNS servers is our own IP
win_dns_client:
adapter_names: "{{ pdc_dns_nics }}"
ipv4_addresses: "{{ ansible_host }}"

- name: Ensure the UserPrincipalName of {{ pdc_netbios }}\{{ pdc_administrator_username }} is set to {{ pdc_administrator_username }}@{{ pdc_domain }}
win_domain_user:
name: "{{ pdc_administrator_username }}"
Expand Down

0 comments on commit 3f0c67a

Please sign in to comment.