Ansible Role bind
This role installs and configures bind as a DNS server. Currently, it only supports standalone configurations, no primary-replica configuration.
If you define a zone with name
, file
and raw
, the role
creates the zone file in
/var/named/{{ item.file }}
creates the corresponding entry in
/etc/named.conf
like so:zone "{{ item.name }}" IN { type master; file "{{ item.file }}"; # do normal iterative resolution (do not forward) forwarders { }; allow-query { trusted; }; allow-transfer { none; }; allow-update { none; }; };
Runs on
RHEL 8 (and compatible)
RHEL 9 (and compatible)
Mandatory Role Variables
Variable |
Description |
---|---|
|
List of networks from which DNS queries are allowed. |
|
List of dictionaries defining the zone files with the DNS records. Subkeys: |
Example:
# mandatory
bind__trusted_networks:
- '192.0.2.0/24'
bind__zones:
- name: 'example.com'
file: 'forward.zone'
raw: |-
$TTL 1H
@ IN SOA dns-server.example.com. root@example.com. (
2022042501 ; <SERNO>
1H ; <TIME-TO-REFRESH>
1H ; <TIME-TO-RETRY>
1W ; <TIME-TO-EXPIRE>
1D ) ; <minimum-TTL>
@ IN NS dns-server.example.com.
_ldap._tcp IN SRV 10 10 389 dns-server.example.com.
dns-server IN A 192.0.2.2
- name: '2.0.192.in-addr.arpa'
file: 'reverse.zone'
raw: |-
$TTL 1H
@ IN SOA dns-server.example.com. info@example.com. (
2022042501 ; <SERNO>
1H ; <TIME-TO-REFRESH>
1H ; <TIME-TO-RETRY>
1W ; <TIME-TO-EXPIRE>
1D ) ; <minimum-TTL>
@ IN NS dns-server.example.com.
2 IN PTR dns-server.example.com.
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
List of DNS servers to which DNS queries to unknown domain names should be forwarded. |
|
|
List of addresses on which the server will listen. This indirectly sets the listening interface(s). |
|
|
Optional, string. Raw content which will be appended to the end of |
unset |
|
Enables or disables the named service, analogous to |
|
|
This enables the usage of a reverse-policy zone (have a look at https://dnsrpz.info/, basically acts as a |
unset |
Example:
# optional
bind__forwarders:
- '1.0.0.1'
- '1.1.1.1'
bind__listen_on_addresses:
- '192.0.2.2/32'
bind__named_conf_raw: |-
zone "example.com" {
type forward;
forwarders { my-dns.loc; };
};
bind__named_service_enabled: true
bind__rpz_zone: 'rpz'
bind__zones:
# make use of the bind__rpz_zone
- name: '{{ bind__rpz_zone }}'
file: '{{ bind__rpz_zone }}.zone'
raw: |-
$TTL 1H
@ IN SOA 001-p-infra01.example.com. info@example.com. (
2022101801 ; <SERNO>
1H ; <TIME-TO-REFRESH>
1H ; <TIME-TO-RETRY>
1W ; <TIME-TO-EXPIRE>
1D ) ; <minimum-TTL>
@ IN NS 001-p-infra01.example.com.
internal-website.example.com A 192.0.2.3