Role that installs and configure the unbound resolver.

This commit is contained in:
Andrea Dell'Amico 2018-05-04 19:47:14 +02:00
parent 7fac63e071
commit f3ad3c6bab
6 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,18 @@
---
unbound_pkgs:
- unbound
- unbound-anchor
- unbound-host
- dig
unbound_interfaces:
- '0.0.0.0'
- '::0'
unbound_allowed_clients:
- { cidr: '0.0.0.0/0', policy: 'allow' }
unbound_verbosity: 1
unbound_threads: '{{ ansible_processor_count }}'
unbound_remote_control: 'no'

View File

@ -0,0 +1,4 @@
---
- name: Restart unbound
service: name=unbound state=restarted

View File

@ -0,0 +1,17 @@
---
- block:
- name: Install the unbound resolver packages
apt: pkg={{ item }} state=latest cache_valid_time=1800 update_cache=yes
with_items: '{{ unbound_pkgs }}'
- name: Install the unbound config files
template: src={{ item }} dest=/etc/unbound/unbound.conf.d/{{ item }}
with_items:
- unbound-server.conf
- unbound-remote-control.conf
notify: Restart unbound
- name: Ensure that the unbound service is started and enabled
service: name=unbound state=started enabled=yes
tags: [ 'unbound' ]

View File

@ -0,0 +1,2 @@
remote-control:
control-enable: {{ unbound_remote_control }}

View File

@ -0,0 +1,34 @@
server:
{% for interface in unbound_interfaces %}
interface: {{ interface }}
{% endfor %}
{% for net in unbound_allowed_clients %}
access-control: {{ net.cidr }} {{ net.policy }}
{% endfor %}
verbosity: {{ unbound_verbosity }}
# use all CPUs
num-threads: {{ unbound_threads }}
# power of 2 close to num-threads
msg-cache-slabs: {{ unbound_threads }}
rrset-cache-slabs: {{ unbound_threads }}
infra-cache-slabs: {{ unbound_threads }}
key-cache-slabs: {{ unbound_threads }}
# more cache memory, rrset=msg*2
rrset-cache-size: 100m
msg-cache-size: 50m
# more outgoing connections
# depends on number of cores: 1024/cores - 50
outgoing-range: {{ 1024 / unbound_threads - 50 }}
# Larger socket buffer. OS may need config.
so-rcvbuf: 4m
so-sndbuf: 4m
# Faster UDP with multithreading (only on Linux).
so-reuseport: yes
# with libevent
outgoing-range: 8192
num-queries-per-thread: 4096