- 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 }}'
