infra/roles/nameservers/tasks/main.yml
2024-01-02 02:10:54 -05:00

45 lines
991 B
YAML

---
## PRIMARY
- name: create named.conf.local for primary
template:
src: ../templates/named.conf.local.primary.j2
dest: /etc/bind/named.conf.local
owner: bind
group: bind
when: inventory_hostname in groups['dnsprimary']
- name: create /etc/bind/zones if not exist
ansible.builtin.file:
path: /etc/bind/zones
state: directory
owner: bind
group: bind
- name: create primary zone files for primary
template:
src: "../templates/{{ item.zone_file }}.j2"
dest: "/etc/bind/zones/{{ item.zone_file }}"
owner: bind
group: bind
with_items: "{{ dns_zones }}"
when: inventory_hostname in groups['dnsprimary']
## REPLICA
- name: create named.conf.local for replica
template:
src: ../templates/named.conf.local.replica.j2
dest: /etc/bind/named.conf.local
owner: bind
group: bind
when: inventory_hostname in groups['dnsreplica']
- name: restart bind9
service:
name: bind9
state: restarted
enabled: true