Add an RPZ blocklist on the Unbound resolvers that returns NXDOMAIN for a set of domains (and subdomains) and logs only those matches under rpz-log tag "blocklist". Domains are templated from resolver_blocked_domains (single source of truth) into /etc/unbound/blocklist.rpz; respip module enabled for RPZ support. Fix deprecation warnings across the Ansible tree: - apt_repository -> deb822_repository (monitor, aprsc, uisp, grafana), removing stale .list files and adding update_cache where deb822 drops it - community.mysql.* -> ansible.mysql.* (monitor) and requirements.yml - top-level facts -> ansible_facts[...] (ansible_os_family, distribution_release, fqdn, architecture, default_ipv4) repo-wide
74 lines
1.7 KiB
YAML
74 lines
1.7 KiB
YAML
---
|
|
# Install and configure BIND9 from scratch
|
|
- name: Install BIND9 packages
|
|
ansible.builtin.apt:
|
|
name:
|
|
- bind9
|
|
- bind9utils
|
|
- bind9-doc
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Create BIND configuration directory
|
|
ansible.builtin.file:
|
|
path: "{{ bind_zone_dir }}"
|
|
state: directory
|
|
owner: bind
|
|
group: bind
|
|
mode: '0755'
|
|
|
|
- name: Deploy named.conf.options
|
|
ansible.builtin.template:
|
|
src: named.conf.options.j2
|
|
dest: /etc/bind/named.conf.options
|
|
owner: root
|
|
group: bind
|
|
mode: '0640'
|
|
notify: Restart bind
|
|
|
|
- name: Deploy named.conf.local
|
|
ansible.builtin.template:
|
|
src: named.conf.local.j2
|
|
dest: /etc/bind/named.conf.local
|
|
owner: root
|
|
group: bind
|
|
mode: '0640'
|
|
notify: Restart bind
|
|
|
|
- name: Deploy main BIND configuration
|
|
ansible.builtin.template:
|
|
src: named.conf.j2
|
|
dest: /etc/bind/named.conf
|
|
owner: root
|
|
group: bind
|
|
mode: '0640'
|
|
validate: 'named-checkconf %s'
|
|
notify: Restart bind
|
|
|
|
- name: Deploy zone files
|
|
ansible.builtin.template:
|
|
src: zone.j2
|
|
dest: "{{ bind_zone_dir }}/{{ item.name }}"
|
|
owner: root
|
|
group: bind
|
|
mode: '0644'
|
|
validate: 'named-checkzone {{ item.name }} %s'
|
|
loop: "{{ bind_zones }}"
|
|
notify: Restart bind
|
|
when: item.type == 'master' or item.type == 'primary'
|
|
tags: deploy_zones
|
|
|
|
- name: Enable and start BIND9 service
|
|
ansible.builtin.service:
|
|
name: "{{ 'bind9' if ansible_facts['os_family'] == 'Debian' else 'named' }}"
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Open DNS port in firewall
|
|
ansible.posix.firewalld:
|
|
zone: public
|
|
service: dns
|
|
permanent: true
|
|
state: enabled
|
|
notify: Restart firewalld
|
|
when: ansible_facts['os_family'] == 'RedHat'
|