Files
semaphore/playbooks/change_dns.yml
T
Claude Sonnet 5 8ff6d59ba6 Restore from Gitea ZIP snapshot (12.08.2026) after full instance reinstall
Git history was lost when the previous Gitea instance was wiped and
reinstalled due to an unresolved corruption bug — this commit is the
last known-good file content, exported before the reinstall. Prior
commit history is not recoverable through this path.
2026-08-12 19:24:02 +00:00

36 lines
1.3 KiB
YAML

---
- name: Auto Configure DNS on Active Adapters
hosts: windows
gather_facts: no
vars:
dns_servers:
- 192.168.1.250
- 192.168.1.254
- 77.88.8.8
tasks:
# 1. Ищем имена активных адаптеров
- name: Find active physical network adapters
ansible.windows.win_shell: |
Get-NetAdapter |
Where-Object { $_.Status -eq 'Up' -and $_.HardwareInterface -eq $true } |
Select-Object -ExpandProperty Name
register: net_adapters
changed_when: false
# 2. Показываем, какие адаптеры нашли (для логов)
- name: Debug - Found Adapters
debug:
msg: "Найдены активные адаптеры: {{ net_adapters.stdout_lines }}"
# 3. Применяем DNS ко всем найденным адаптерам
- name: Set DNS Servers
ansible.windows.win_dns_client:
adapter_names: "{{ item }}"
ipv4_addresses: "{{ dns_servers }}"
# Цикл пройдется по каждому найденному адаптеру (например, и Ethernet, и Wi-Fi)
loop: "{{ net_adapters.stdout_lines }}"
# 4. Очищаем кэш
- name: Flush DNS Cache
ansible.windows.win_shell: ipconfig /flushdns