mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
win_dns_record (#51925)
* win_dns: Initial work * win_dns: initial commit * Renaming win_dns -> win_dns_record * win_dns_record: Fix record leakage in output * win_dns_record: Fix erroneous minimums enforcement It is apparently completely legitimate to specify a TTL that is below minimum; it will just get ignored in favor of the server's minimum. * win_dns_record: Fix new-host changes reported incorrectly * win_dns_record: Fix TTL changes reported incorrectly * win_dns_record: Fix existing records not recognized * win_dns_record: Remove obsolete object * Refactorize check mode * Add computer_name parameter * Refactorize diff and changed to read DNS end state * Fix pslint tests PSUseDeclaredVarsMoreThanAssignments and PSAvoidUsingCmdletAliases * Minor fix, misnamed variable. * win_dns_record: Fix "changed" state in check mode * win_dns_record: cleanups * win_dns_record: fix TTL update not changed regression * Add initial integration tests * win_dns_record: integration tests * win_dns_record: Reverted 9cf5f2d8e6507cf477ab9e7ca166b1857169d6b5 The approach from that commit breaks check mode. * win_dns_record: de-scope some records These are either esoteric (meaning limited realworld testing) or require additional thought to do properly (eg MX, which has its "priority" level). * win_dns_records tests: Ensure DNS services are installed * Update lib/ansible/modules/windows/win_dns_record.py Co-Authored-By: johnboy2 * Update lib/ansible/modules/windows/win_dns_record.py Co-Authored-By: johnboy2 * Aggregated suggestions from dagwieers * Fix bad powershell test argument * win_dns_record partially converted to new Powershell module interface win_dns_record converted to new Powershell module interface, except diff and required_if * win_dns_record: convert diff support * win_dns_record: convert diff support to after-before style * Don't test for Add-WindowsFeature * win_dns_record: Fix diff When check mode is used diff changes must be simulated. * Style consistency/clean-ups * Fix integration test typos * Improve readability of diff output The original intention of the diff output was to resemble zone file records (except that the zone-name is added onto each record). In that light, the missing *record class* information (always "IN" in our case) was an oversight. This just makes the diff output more "instantly readable" for DNS gurus. * win_dns_record: Add diff tests * Fix ansible-test sanity check fails * Apply suggestions from code review Added suggestions from dagwieers Co-Authored-By: johnboy2 <john@jnelson.ca> * win_dns_record: Skip 2008 and friends * Reword error messages so they start capitalized. * Fix sanity error * win_dns_record: Document ttl range * win_dns_record: Additional supportability barriers in tests * win_dns_record: Typo * win_dns_record: Sanity fix * win_dns_record: Use OS-test only for compat checking
This commit is contained in:
committed by
Jordan Borean
parent
9744ef80a0
commit
38346d0337
3
test/integration/targets/win_dns_record/aliases
Normal file
3
test/integration/targets/win_dns_record/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
shippable/windows/group2
|
||||
skip/windows/2008
|
||||
skip/windows/2008-R2
|
||||
@@ -0,0 +1,3 @@
|
||||
win_dns_record_zone: test.ansible.local
|
||||
win_dns_record_revzone: 0.0.255.in-addr.arpa
|
||||
win_dns_record_revzone_network: 255.0.0.0/24
|
||||
17
test/integration/targets/win_dns_record/tasks/clean.yml
Normal file
17
test/integration/targets/win_dns_record/tasks/clean.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
- name: Remove test zone, if present
|
||||
win_shell: |
|
||||
$zone = '{{ item }}'
|
||||
$fail_on_missing = '{{ fail_on_missing | default(true) }}'
|
||||
|
||||
Trap { If (-not $fail_on_missing) { continue } }
|
||||
Remove-DnsServerZone -Name $zone -Force
|
||||
|
||||
# win_file could also do this, but it would need to know where the
|
||||
# SystemRoot is located via fact gathering, which we cannot assume.
|
||||
Trap { If (-not $fail_on_missing) { continue } }
|
||||
Remove-Item -Path $env:SystemRoot\system32\dns\$zone.dns
|
||||
|
||||
$true # so pipeline exits cleanly if an error was ignored above
|
||||
loop:
|
||||
- '{{ win_dns_record_zone }}'
|
||||
- '{{ win_dns_record_revzone }}'
|
||||
12
test/integration/targets/win_dns_record/tasks/main.yml
Normal file
12
test/integration/targets/win_dns_record/tasks/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
# We do an explicit OS version check here *INSTEAD OF* the usual test for
|
||||
# cmdlet existence. That's because a cmdlet test here won't work without first
|
||||
# installing the DNS feature, but we don't want to install the feature on OS'
|
||||
# that can't be supported anyway. Hence this fallback to an explicit OS version
|
||||
# test.
|
||||
- name: check OS version is supported
|
||||
win_shell: 'if ([Environment]::OSVersion.Version -ge [Version]"6.2") { $true } else { $false }'
|
||||
register: os_supported
|
||||
|
||||
- name: run tests on supported hosts
|
||||
include: tests.yml
|
||||
when: os_supported.stdout | trim | bool
|
||||
186
test/integration/targets/win_dns_record/tasks/tests-A.yml
Normal file
186
test/integration/targets/win_dns_record/tasks/tests-A.yml
Normal file
@@ -0,0 +1,186 @@
|
||||
- name: 'TYPE=A - creation (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=A - creation get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - creation check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=A - creation'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - creation get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - creation check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '1.2.3.4\r\n'
|
||||
|
||||
- name: 'TYPE=A - creation (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - creation get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - creation check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '1.2.3.4\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=A - update address (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=A - update address get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update address check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '1.2.3.4\r\n'
|
||||
|
||||
- name: 'TYPE=A - update address'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - update address get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update address check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '5.6.7.8\r\n'
|
||||
|
||||
- name: 'TYPE=A - update address (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - update address get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update address check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '5.6.7.8\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=A - update TTL (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=A - update TTL get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update TTL check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '3600\r\n'
|
||||
|
||||
- name: 'TYPE=A - update TTL'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - update TTL get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update TTL check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
- name: 'TYPE=A - update TTL (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - update TTL get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - update TTL check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=A - remove record (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=A - remove record get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - remove record check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'exists\r\n'
|
||||
|
||||
- name: 'TYPE=A - remove record'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - remove record get results'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - remove record check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=A - remove record (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=A - remove record get results (idempotent)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=A - remove record check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
186
test/integration/targets/win_dns_record/tasks/tests-AAAA.yml
Normal file
186
test/integration/targets/win_dns_record/tasks/tests-AAAA.yml
Normal file
@@ -0,0 +1,186 @@
|
||||
- name: 'TYPE=AAAA - creation (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=AAAA - creation get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - creation check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - creation'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - creation get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - creation check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '2001:db8::1\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - creation (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - creation get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - creation check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '2001:db8::1\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=AAAA - update address (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=AAAA - update address get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update address check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '2001:db8::1\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - update address'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - update address get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update address check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '2001:db8::2\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - update address (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - update address get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update address check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '2001:db8::2\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '3600\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update TTL check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - update address (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - update address get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - update address check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=AAAA - remove record (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=AAAA - remove record get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - remove record check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'exists\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - remove record'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - remove record get results'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - remove record check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=AAAA - remove record (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=AAAA - remove record get results (idempotent)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=AAAA - remove record check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
186
test/integration/targets/win_dns_record/tasks/tests-CNAME.yml
Normal file
186
test/integration/targets/win_dns_record/tasks/tests-CNAME.yml
Normal file
@@ -0,0 +1,186 @@
|
||||
- name: 'TYPE=CNAME - creation (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=CNAME - creation get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - creation check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - creation'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - creation get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - creation check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'www.ansible.com.\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - creation (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - creation get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - creation check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'www.ansible.com.\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=CNAME - update address (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=CNAME - update address get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update address check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'www.ansible.com.\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - update address'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - update address get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update address check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'docs.ansible.com.\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - update address (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - update address get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update address check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'docs.ansible.com.\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '3600\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - update TTL check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=CNAME - remove record (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=CNAME - remove record get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - remove record check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'exists\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - remove record'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - remove record get results'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - remove record check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=CNAME - remove record (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=CNAME - remove record get results (idempotent)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=CNAME - remove record check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
186
test/integration/targets/win_dns_record/tasks/tests-PTR.yml
Normal file
186
test/integration/targets/win_dns_record/tasks/tests-PTR.yml
Normal file
@@ -0,0 +1,186 @@
|
||||
- name: 'TYPE=PTR - creation (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=PTR - creation get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - creation check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - creation'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - creation get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - creation check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - creation (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - creation get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - creation check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=PTR - update address (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=PTR - update address get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update address check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - update address'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - update address get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update address check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'ansible-altmirror.example.com.\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - update address (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - update address get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update address check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'ansible-altmirror.example.com.\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=PTR - update TTL (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=PTR - update TTL get results (check mode)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update TTL check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '3600\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - update TTL'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - update TTL get results'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update TTL check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - update TTL (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - update TTL get results (idempotent)'
|
||||
win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - update TTL check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == '7200\r\n'
|
||||
|
||||
|
||||
- name: 'TYPE=PTR - remove record (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent}
|
||||
register: cmd_result
|
||||
check_mode: yes
|
||||
|
||||
- name: 'TYPE=PTR - remove record get results (check mode)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - remove record check results (check mode)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'exists\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - remove record'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - remove record get results'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - remove record check results'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
|
||||
- name: 'TYPE=PTR - remove record (idempotent)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent}
|
||||
register: cmd_result
|
||||
|
||||
- name: 'TYPE=PTR - remove record get results (idempotent)'
|
||||
win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }"
|
||||
register: cmd_result_actual
|
||||
changed_when: false
|
||||
|
||||
- name: 'TYPE=PTR - remove record check results (idempotent)'
|
||||
assert:
|
||||
that:
|
||||
- cmd_result is not changed
|
||||
- cmd_result_actual.stdout == 'absent\r\n'
|
||||
63
test/integration/targets/win_dns_record/tasks/tests-diff.yml
Normal file
63
test/integration/targets/win_dns_record/tasks/tests-diff.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
# Diff tests are present because those records have to be created MANUALLY by
|
||||
# the win_dns_record module when in check mode, as there is otherwise no way in
|
||||
# Windows DNS to *simulate* a record or change.
|
||||
|
||||
|
||||
- name: 'Diff test - creation (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A}
|
||||
register: create_check
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - creation'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A}
|
||||
register: create_do
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - creation check results'
|
||||
assert:
|
||||
that:
|
||||
- create_check.diff.before == create_do.diff.before
|
||||
- create_check.diff.before == ''
|
||||
- create_check.diff.after == create_do.diff.after
|
||||
- create_check.diff.after == "[{{ win_dns_record_zone }}] diff_host 3600 IN A 1.2.3.4\n"
|
||||
|
||||
|
||||
- name: 'Diff test - update TTL (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A, ttl: 7200}
|
||||
register: update_check
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - update TTL'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A, ttl: 7200}
|
||||
register: update_do
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - update TTL check results'
|
||||
assert:
|
||||
that:
|
||||
- update_check.diff.before == update_do.diff.before
|
||||
- update_check.diff.before == "[{{ win_dns_record_zone }}] diff_host 3600 IN A 1.2.3.4\n"
|
||||
- update_check.diff.after == update_do.diff.after
|
||||
- update_check.diff.after == "[{{ win_dns_record_zone }}] diff_host 7200 IN A 1.2.3.4\n"
|
||||
|
||||
|
||||
- name: 'Diff test - deletion (check mode)'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, type: A, state: absent}
|
||||
register: delete_check
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - deletion'
|
||||
win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, type: A, state: absent}
|
||||
register: delete_do
|
||||
diff: yes
|
||||
|
||||
- name: 'Diff test - deletion check results'
|
||||
assert:
|
||||
that:
|
||||
- delete_check.diff.before == delete_do.diff.before
|
||||
- delete_check.diff.before == "[{{ win_dns_record_zone }}] diff_host 7200 IN A 1.2.3.4\n"
|
||||
- delete_check.diff.after == delete_do.diff.after
|
||||
- delete_check.diff.after == ''
|
||||
32
test/integration/targets/win_dns_record/tasks/tests.yml
Normal file
32
test/integration/targets/win_dns_record/tasks/tests.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
- name: ensure DNS services are installed
|
||||
win_feature:
|
||||
name: DNS
|
||||
state: present
|
||||
register: dns_install
|
||||
|
||||
- name: reboot server if needed
|
||||
win_reboot:
|
||||
when: dns_install.reboot_required
|
||||
|
||||
- name: Clean slate
|
||||
import_tasks: clean.yml
|
||||
vars:
|
||||
fail_on_missing: false
|
||||
|
||||
- block:
|
||||
- name: Create the forward zone
|
||||
win_shell: Add-DnsServerPrimaryZone -Name '{{ win_dns_record_zone }}' -ZoneFile '{{ win_dns_record_zone}}.dns'
|
||||
- name: Create the reverse zone
|
||||
win_shell: Add-DnsServerPrimaryZone -NetworkID '{{ win_dns_record_revzone_network }}' -ZoneFile '{{ win_dns_record_revzone}}.dns'
|
||||
|
||||
- import_tasks: tests-A.yml
|
||||
- import_tasks: tests-AAAA.yml
|
||||
- import_tasks: tests-CNAME.yml
|
||||
- import_tasks: tests-PTR.yml
|
||||
- import_tasks: tests-diff.yml
|
||||
|
||||
always:
|
||||
- name: Clean slate
|
||||
import_tasks: clean.yml
|
||||
vars:
|
||||
fail_on_missing: true
|
||||
Reference in New Issue
Block a user