Обновить test-playbooks/win_dns_ps.yml
This commit is contained in:
@@ -1,10 +1,34 @@
|
|||||||
---
|
---
|
||||||
- name: win_powershell_exec
|
- name: Check and Configure DNS on Windows
|
||||||
hosts: all
|
hosts: windows
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_connection: winrm
|
||||||
|
ansible_winrm_server_cert_validation: ignore
|
||||||
|
ansible_shell_type: powershell
|
||||||
|
ansible_remote_tmp: C:\Windows\Temp
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: check DNS
|
- name: Get all active network adapters
|
||||||
win_shell: |
|
ansible.windows.win_shell: |
|
||||||
Get-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter|where Status -eq "Up").ifindex -ErrorAction SilentlyContinue
|
Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | Select-Object Name, InterfaceIndex, Status
|
||||||
register: command_output
|
register: adapters
|
||||||
- name: command output
|
|
||||||
ansible.builtin.debug:
|
- name: Display active adapters
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: adapters.stdout_lines
|
||||||
|
|
||||||
|
- name: Check DNS for each active adapter
|
||||||
|
ansible.windows.win_shell: |
|
||||||
|
$adapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" }
|
||||||
|
foreach ($adapter in $adapters) {
|
||||||
|
Write-Output "=== Adapter: $($adapter.Name) ==="
|
||||||
|
Get-DnsClientServerAddress -InterfaceIndex $adapter.InterfaceIndex
|
||||||
|
Write-Output ""
|
||||||
|
}
|
||||||
|
register: dns_info
|
||||||
|
|
||||||
|
- name: Show DNS information
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: dns_info.stdout_lines
|
||||||
Reference in New Issue
Block a user