So I've got a project at work that's allowing me to use more Ansible.. and I love it! Anyway we've been using Cisco's Umbrella appliances for safe DNS services but now they are going away. So.. what to do about all the servers currently using those servers in a static fashion?
So in this situation Windows was actually a bit easier. We have three main sites and a few smaller locations that do not contain their own DNS servers. So this play associates the smaller sites subnets with the nearest main site. So after much assistance from #ansible on Libera.Chat here is what I have:
---
- name: Replacing Umbrella DNS on Windows
hosts: "{{ targets }}"
become: yes
become_method: runas
tasks:
- name: Edit Site1 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.10.16.11
- 10.10.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.10.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.25.0.0/16') | list)"
- name: Edit Site2 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.11.16.11
- 10.11.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.11.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.30.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.20.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.18.0.0/16') | list)"
- name: Edit Site3 DNS Settings on all network interfaces
win_dns_client:
adapter_names: '*'
ipv4_addresses:
- 10.13.16.11
- 10.13.16.12
log_path: C:\dns_log.txt
when: "(ansible_ip_addresses | ipaddr('10.13.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.22.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.21.0.0/16') | list)
or (ansible_ip_addresses | ipaddr('10.44.0.0/16') | list)"
Next post I'll make is handling Linux. thanks!