Code Monkey home page Code Monkey logo

ansible-role-bind's Introduction

Ansible role BIND

Actions Status

An Ansible role for setting up ISC BIND as an authoritative-only DNS server for multiple domains. Specifically, the responsibilities of this role are to:

  • install BIND
  • set up the main configuration file (primary/secondary/forwarder server)
  • set up forward and reverse lookup zone files

This role supports multiple forward and reverse zones, including for IPv6. Although enabling recursion is supported (albeit strongly discouraged), consider using another role if you want to set up a caching or forwarding name server.

If you like/use this role, please consider giving it a star and rating it on the role's Ansible Galaxy page. Thanks!

See the change log for notable changes between versions.

WARNING: If you've been using this role since before v5.0.0, please check the change log for important information on breaking changes. Old playbooks will fail if you upgrade to v5.0.0.

Supported platforms

This role can be used on several platforms, see meta/main.yml for an updated list. We strive to set up automated tests for each supported platform (see .ci.yml), but this is not always possible.

A few remarks on supported roles that are not included in automated tests

  • Arch Linux and FreeBSD should work, but at this time, it's not possible to test the role on these distros, since no suitable Docker images are available.
  • CentOS 6 should work, but idempotence tests fail even if BIND is installed successfully and acceptance tests succeed.

Requirements

The packages python-netaddr (required for the ipaddr filter) and dnspython should be installed on the management node

Role Variables

Variable Default Comments (type)
bind_acls [] A list of ACL definitions, which are mappings with keys name: and match_list:. See below for an example.
bind_allow_query ['localhost'] A list of hosts that are allowed to query this DNS server. Set to ['any'] to allow all hosts
bind_allow_recursion ['any'] Similar to bind_allow_query, this option applies to recursive queries.
bind_check_names [] Check host names for compliance with RFC 952 and RFC 1123 and take the defined action (e.g. warn, ignore, fail).
bind_dns_keys [] A list of binding keys, which are mappings with keys name: algorithm: and secret:. See below for an example.
bind_dns64 false If true, support for DNS64 is enabled
bind_dns64_clients ['any'] A list of clients which the DNS64 function applies to (can be any ACL)
bind_dnssec_enable true If true, DNSSEC is enabled
bind_dnssec_validation true If true, DNSSEC validation is enabled
bind_extra_include_files [] A list of custom config files to be included from the main config file
bind_forward_only false If true, BIND is set up as a caching name server
bind_forwarders [] A list of name servers to forward DNS requests to.
bind_listen_ipv4 ['127.0.0.1'] A list of the IPv4 address of the network interface(s) to listen on. Set to ['any'] to listen on all interfaces.
bind_listen_ipv4_port [53] A list of port numbers to listen on for IPv4 addresses.
bind_listen_ipv6 ['::1'] A list of the IPv6 address of the network interface(s) to listen on
bind_listen_ipv6_port [53] A list of port numbers to listen on for IPv6 addresses.
bind_log data/named.run Path to the log file
bind_other_logs - A list of logging channels to configure, with a separate mapping for each zone, with relevant details
bind_query_log - A mapping with keyss file: (e.g. data/query.log), versions:, size:. When defined, this will enable the query log
bind_recursion false Determines whether requests for which the DNS server is not authoritative should be forwarded†.
bind_rrset_order random Defines order for DNS round robin (either random or cyclic)
bind_statistics_channels false If true, BIND is configured with a statistics-channels clause (currently only supports listening on a single interface)
bind_statistics_allow ['127.0.0.1'] A list of hosts that can access the server statistics
bind_statistics_host 127.0.0.1 IP address of the network interface that the statistics service should listen on
bind_statistics_port 8053 Network port that the statistics service should listen on
bind_zone_dir - When defined, sets a custom absolute path to the server directory (for zone files, etc.) instead of the default.
bind_key_mapping [] Primary: Keyname - mapping of TSIG keys to use for a specific primary
bind_zones n/a A list of mappings with zone definitions. See below this table for examples
- allow_update ['none'] A list of hosts that are allowed to dynamically update this DNS zone.
- also_notify - A list of servers that will receive a notification when the primary zone file is reloaded.
- create_forward_zones - When initialized and set to false, creation of forward zones will be skipped (resulting in a reverse only zone)
- create_reverse_zones - When initialized and set to false, creation of reverse zones will be skipped (resulting in a forward only zone)
- delegate [] Zone delegation.
- forwarders - List of forwarders for for the forward type zone
- hostmaster_email hostmaster The e-mail address of the system administrator for the zone
- hosts [] Host definitions.
- ipv6_networks [] A list of the IPv6 networks that are part of the domain, in CIDR notation (e.g. 2001:db8::/48)
- mail_servers [] A list of mappings (with keys name: and preference:) specifying the mail servers for this domain.
- name_servers [ansible_hostname] A list of the DNS servers for this domain.
- name example.com The domain name
- naptr [] A list of mappings with keys name:, order:, pref:, flags:, service:, regex: and replacement: specifying NAPTR records.
- networks ['10.0.2'] A list of the networks that are part of the domain
- other_name_servers [] A list of the DNS servers outside of this domain.
- primaries - A list of primary DNS servers for this zone.
- services [] A list of services to be advertised by SRV records
- text [] A list of mappings with keys name: and text:, specifying TXT records. text: can be a list or string.
- caa [] A list of mappings with keys name: and text:, specifying CAA records. text: can be a list or string.
- type - Optional zone type. If not specified, autodetection will be used. Possible values include primary, secondary or forward
bind_zone_file_mode 0640 The file permissions for the main config file (named.conf)
bind_zone_minimum_ttl 1D Minimum TTL field in the SOA record.
bind_zone_time_to_expire 1W Time to expire field in the SOA record.
bind_zone_time_to_refresh 1D Time to refresh field in the SOA record.
bind_zone_time_to_retry 1H Time to retry field in the SOA record.
bind_zone_ttl 1W Time to Live field in the SOA record.
bind_python_version - The python version that should be used for ansible. Depends on Distro, either 2 or 3. Defaults to the OS standard

† Best practice for an authoritative name server is to leave recursion turned off. However, for some cases it may be necessary to have recursion turned on.

Minimal variables for a working zone

In order to set up an authoritative name server that is available to clients, you should at least define the following variables:

Variable Primary Secondary Forward
bind_allow_query V V V
bind_listen_ipv4 V V V
bind_zones V V V
- hosts V -- --
- name_servers V -- --
- name V V --
- networks V V V
- primaries V V --
- forwarders -- -- V

Domain definitions

bind_zones:
  # Example of a primary zone (hosts: and name_servers: ares defined)
  - name: mydomain.com           # Domain name
    create_reverse_zones: false  # Skip creation of reverse zones
    primaries:
      - 192.0.2.1                # Primary server(s) for this zone
    name_servers:
      - pub01.mydomain.com.
      - pub02.mydomain.com.
    hosts:
      - name: pub01
        ip: 192.0.2.1
        ipv6: 2001:db8::1
        aliases:
          - ns1
      - name: pub02
        ip: 192.0.2.2
        ipv6: 2001:db8::2
        aliases:
          - ns2
      - name: '@'                # Enables "http://mydomain.com/"
        ip:
          - 192.0.2.3            # Multiple IP addresses for a single host
          - 192.0.2.4            #   results in DNS round robin
        sshfp:                   # Secure shell fingerprint
          - "3 1 1262006f9a45bb36b1aa14f45f354b694b77d7c3"
          - "3 2 e5921564252fe10d2dbafeb243733ed8b1d165b8fa6d5a0e29198e5793f0623b"
        ipv6:
          - 2001:db8::2
          - 2001:db8::3
        aliases:
          - www
      - name: priv01             # This IP is in another subnet, will result in
        ip: 10.0.0.1             #   multiple reverse zones
      - name: mydomain.net.
        aliases:
          - name: sub01
            type: DNAME          # Example of a DNAME alias record
    networks:
      - '192.0.2'
      - '10'
      - '172.16'
    delegate:
      - zone: foo
        dns: 192.0.2.1
    services:
      - name: _ldap._tcp
        weight: 100
        port: 88
        target: dc001
    naptr:                       # Name Authority Pointer record, used for IP
      - name: "sip"              #   telephony
        order: 100
        pref: 10
        flags: "S"
        service: "SIP+D2T"
        regex: "!^.*$!sip:[email protected]!"
        replacement: "_sip._tcp.example.com."
  # Minimal example of a secondary zone
  - name: acme.com
    primaries:
      - 172.17.0.2
    networks:
      - "172.17"
  # Minimal example of a forward zone
  - name: acme.com
    forwarders:
      - 172.17.0.2
    networks:
      - "172.17"

Hosts

Host names that this DNS server should resolve can be specified in bind_zones.hosts as a list of mappings with keys name:, ip:, aliases: and sshfp:. Aliases can be CNAME (default) or DNAME records.

To allow to surf to http://example.com/, set the host name of your web server to '@' (must be quoted!). In BIND syntax, @ indicates the domain name itself.

If you want to specify multiple IP addresses for a host, add entries to bind_zones.hosts with the same name (e.g. priv01 in the code snippet). This results in multiple A/AAAA records for that host and allows DNS round robin, a simple load balancing technique. The order in which the IP addresses are returned can be configured with role variable bind_rrset_order.

Networks

As you can see, not all hosts are in the same subnet. This role will generate suitable reverse lookup zones for each subnet. All subnets should be specified in bind_zones.networks, though, or the host will not get a PTR record for reverse lookup.

Remark that only the network part should be specified here! When specifying a class B IP address (e.g. "172.16") in a variable file, it must be quoted. Otherwise, the Yaml parser will interpret it as a float.

Based on the idea and examples detailed at https://linuxmonk.ch/wordpress/index.php/2016/managing-dns-zones-with-ansible/ for the gdnsd package, the zone files are fully idempotent, and thus only get updated if "real" content changes.

Zone types and Zone type auto-detection

Zone type is an optional zone parameter that defines if the zone type should be of primary, secondary or forward type. When type parameter is omitted, zone type will be autodetected based on the intersection of host IP addresses and primaries record when configuring primary or secondary zone. When primaries is not defined and forwarders is defined, the zone type will be set to forward.

Zone auto-detection functionality is especially useful when deploying multi-site DNS infrastructure. It is convenient to have a "shared" bind_zones definitions in a single group inventory file for all dns servers ( ex. group_vars\dns.yml). Such an approach allows to switch between primary and secondary server(s) roles by updating primaries record only and rerunning the playbook. Zone type auto-detection can be tested with "shared_inventory" molecule scenario by running: molecule test --scenario-name shared_inventory


NOTE

  • bind doesn't support automated multi-master configuration and primaries list should have a single entry only.
  • When primaries record is updated to switch primary to secondary server roles, zones will be wiped out and recreated from template as we yet to support dynamic updates for existing zones.

Zone types can be also defined explicitly in per host inventory to skip autodetection:

# Primary Server
bind_zones:
  - name: mydomain.com
    type: primary
    primaries:
      - 192.0.2.1
...
# Secondary Server
bind_zones:
  - name: mydomain.com
      type: secondary
      primaries:
        - 192.0.2.1
...
# Forwarder Server
bind_zones:
  - name: anotherdomain.com
      type: forward
      forwarders:
        - 192.0.3.1

Zone delegation

To delegate a zone to a DNS server, it is sufficient to create a NS record (under delegate) which is the equivalent of:

foo IN NS 192.0.2.1

Service records

Service (SRV) records can be added with the services. This should be a list of mappings with mandatory keys name: (service name), target: (host providing the service), port: (TCP/UDP port of the service) and optional keys priority: (default = 0) and weight: (default = 0).

ACLs

ACLs can be defined like this:

bind_acls:
  - name: acl1
    match_list:
      - 192.0.2.0/24
      - 10.0.0.0/8

The names of the ACLs will be added to the allow-transfer clause in global options.

Binding Keys

Binding keys can be defined like this:

bind_dns_keys:
  - name: primary_key
    algorithm: hmac-sha256
    secret: "azertyAZERTY123456"
bind_extra_include_files:
  - "{{ bind_auth_file }}"

tip: Extra include file must be set as an ansible variable because file is OS dependant

This will be set in a file "{{ bind_auth_file }} (e.g. /etc/bind/auth_transfer.conf for Debian) which have to be added in the list variable bind_extra_include_files

Using TSIG for zone transfer (XFR) authorization

To authorize the transfer of zone between primary & secondary servers based on a TSIG key, set the mapping in the variable bind_key_mapping:

bind_key_mapping:
  primary_ip: TSIG-keyname

Each primary can only have one key (per view).

A check will be performed to ensure the key is actually present in the bind_dns_keys mapping. This will add a server statement for the a in bind_auth_file on a secondary server containing the specified key.

Dependencies

No dependencies.

Example Playbooks

See the test playbooks and inventory for an elaborate example that showcases most features.

Standard Inventory

tree --dirsfirst molecule/default
molecule/default
├── group_vars
│   └── all.yml
├── host_vars
│   ├── ns1.yml    # Primary
│   ├── ns2.yml    # Secondary
│   └── ns3.yml    # Forwarder
├── converge.yml
...

Shared Inventory

Variables common between primary and secondary servers defined in all.yml

tree --dirsfirst molecule/shared_inventory
molecule/shared_inventory
├── group_vars
│   └── all.yml
├── converge.yml
...

Testing

This role is tested using Ansible Molecule. Tests are launched automatically on Github Actions after each commit and PR.

This Molecule configuration will:

  • Run Yamllint and Ansible Lint
  • Create three Docker containers, one primary (ns1), one secondary (ns2) DNS server and forwarder(ns3) - default molecule scenario
  • Run a syntax check
  • Apply the role with a test playbook and check idempotence
  • Run acceptance tests with verify playbook
  • Create two additional Docker containers, one primary(ns4) and one secondary (ns5) and run shared_inventory scenario

This process is repeated for all the supported Linux distributions.

Local test environment

In order to run the acceptance tests on this role locally, you can install the necessary tools on your machine, or use this reproducible setup in a VirtualBox VM (set up with Vagrant): https://github.com/bertvv/ansible-testenv.

Steps to install the tools manually:

  1. Docker should be installed on your machine
  2. As recommended by Molecule, create a python virtual environment
  3. Install the software tools python3 -m pip install molecule molecule-docker docker netaddr dnspython yamllint ansible-lint
  4. Navigate to the root of the role directory and run molecule test

Molecule automatically deletes the containers after a test. If you would like to check out the containers yourself, run molecule converge followed by molecule login --host HOSTNAME.

The Docker containers are based on images created by Jeff Geerling, specifically for Ansible testing (look for images named geerlingguy/docker-DISTRO-ansible). You can use any of his images, but only the distributions mentioned in meta/main.yml are supported.

The default config will start three Centos 8 containers (the primary supported platform at this time). Choose another distro by setting the MOLECULE_DISTRO variable with the command, e.g.:

MOLECULE_DISTRO=debian9 molecule test

or

MOLECULE_DISTRO=debian9 molecule converge

You can run the acceptance tests on all servers with molecule verify.

Verification tests are done using "dig" lookup module by quering dns records and validating responses. This requires direct network communication between Ansible controller node (your machine running Ansible) and the target docker container.


NOTE

Molecule verify tests will fail if docker is running on MacOS, as MacOS cannot access container IP directly. This is a known issue. See #2670.

Workaround:

  1. Run molecule linter: molecule lint
  2. Provision containers: molecule converge
  3. Connect to container: molecule login --host ns1
  4. Go to role directory: cd /etc/ansible/roles/bertvv.bind
  5. Run verify playbook:
ansible-playbook -c local -i "`hostname`," -i molecule/default/inventory.ini molecule/default/verify.yml
  1. Repeat steps 2-4 for ns2 and ns3

License

BSD

Contributors

This role could only have been realized thanks to the contributions of many. If you have an idea to improve it even further, don't hesitate to pitch in!

Issues, feature requests, ideas, suggestions, etc. can be posted in the Issues section.

Pull requests are also very welcome. Please create a topic branch for your proposed changes. If you don't, this will create conflicts in your fork after the merge. Don't hesitate to add yourself to the contributor list below in your PR!

Maintainers:

Contributors:

ansible-role-bind's People

Contributors

aido avatar bdurrow avatar bertvv avatar blofeldthefish avatar bverschueren avatar chicks-net avatar dhaines avatar fazlearefin avatar flora-five avatar frock81 avatar gdarmont avatar gergnz avatar gr360ry avatar jadjay avatar jdelaporte avatar jeichhorn avatar kartone avatar kornrunner avatar lhw avatar mihudec avatar pauliusm avatar pecastro avatar psa avatar rafi avatar rds13 avatar robinoph avatar s-newman avatar sdwilsh avatar seberm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-bind's Issues

Ansible 2.0 bug

Try run playbook with your role using Ansible 2.0. It ends with error:

ERROR! 'version' is not a valid attribute for a RoleMetadata

The error appears to have been in '/etc/ansible/roles/bertvv.bind/meta/main.yml': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
galaxy_info:
^ here

NS records for parent domain's nameservers...subdomain is appended to FQDN

So, my domain is a a child domain of my college's domain. I need to have NS records for the NS servers that are authoritatively serving records I transfer to them. I also transfer records to our ISP, who serves my zone authoritatively. I have the need to put their records in the file appearing like so:

                IN  NS     ns1.mydomain.college.edu.
                 IN  NS     ns2.mydomain.college.edu.
                 IN  NS     dns1.college.edu..mydomain.college.edu.
                 IN  NS     dns2.college.edu..mydomain.college.edu.
                 IN  NS     ns1.ISP.net..mydomain.college.edu.
                 IN  NS     ns2.ISP.net..mydomain.college.edu.

I have thought about this for a bit, and it seems easiest to change the variable to be the FQDN, and not append the domain name at all in the template.

As a reference, Zytrax.com states, "There is no requirement that any name servers are within the domain for which they are authoritative." http://www.zytrax.com/books/dns/ch8/ns.html

error: zone has no A address records

Hi, thanks for this awesome role!

I have an issue where a simple zone couldn't be created because of a strange error I see. Thats my playbook:

---
- hosts: all
  become: true
  vars:
    bind_allow_query:
      - any
    bind_listen_ipv4:
      - any
    bind_zone_master_server_ip: 10.99.99.8
    bind_zone_domains:
      - name: 'nuage.internet'
        networks:
          - '10.99.99'
        name_servers:
          - ns1.nuage.internet.
        hosts:
          - name: utility
            ip: 10.99.99.8
            alias:
              - dns
          - name: vsc1
            ip: 10.99.99.4
          - name: vsc1
            ip: 10.99.99.5
          - name: vsc1
            ip: 10.99.99.6
          - name: vsc1
            ip: 10.99.99.7
  roles:
    - ansible-role-bind

The error is:

"stdout": "zone nuage.internet/IN: NS 'ns1.nuage.internet' has no address records (A or AAAA)
zone nuage.internet/IN: not loaded due to errors."

I am a bit lost, why cant I use

 name_servers:
          - ns1.nuage.internet.

as my SOA? If I change this line to, say, acme.local. everything works, but is it a correct behavior?

Recursion ... can we have it back?

I know you had recursion originally, and then removed it. I now have the need to allow recursion only for localnets, which requires having recursion turned on. Apparently, localnets and localhost is the default access list if you turn on recursion and don't specify additional hosts. I don't know how the "allow-query" statement affects that, however. There is a statement specifically for allow-query-cache that can have its own set of allowed hosts.

If you don't want to add this back into your role, I understand. I'll be tweaking my template to turn it back on for my environment.

http://www.zytrax.com/books/dns/ch7/queries.html#allow-query-cache
https://kb.isc.org/article/AA-00503/0/Whats-the-difference-between-allow-query-cache-and-allow-recursion.html

Add `forwarders` option

Adding the forwarders option makes the role more useful for setting up a caching name server. This was not the initial intended use of this role, but there is some demand for it.

`recursion` should be off by default

The way this role is set up is suitable for an authoritative name server. Best practices state that recursion should be turned off in that case. The default settings should reflect this.

bind_zone_hosts from inventory

Hi,

Is it possible to populate the bind_zone_hosts variable with values from the inventory?

The following in group_vars reports an error 'item' is undefined

bind_zone_hosts:
  - name: "{{ item }}"
    ip: "{{ hostvars['{{ item }}']['ansible_host'] }}"
    with_items: "{{ groups['all'] }}"

multi server

if i have multi server, example 3 hardware server.
ns1.domain.tld (master)
ns2.domain.tld (slave)
ns3.domain.tld (slave)

my hosts is
[dns-server]
ns1.domain.tld ansible_user=root ansible_port=2400
ns2.domain.tld ansible_user=root ansible_port=2400
ns3.domain.tld ansible_user=root ansible_port=2400

how can I say that ns1 is master and ns2 and ns3 is slave?

Default `mail_servers` is not working

According to the README, a the mail_servers zone variable defaults to [{name: mail, preference: 10}].

However, in the bind_zone.j2 template file it seems to default to [].

Either the README or the template should be changed.

For slave servers, SELinux needs adjusting to allow zone files to be written

Zone transfers fail with: "dumping master file: tmp-xxxxxxxxxxxxx: open: permission denied" on slaves.

To resolve, on slave issue:
setsebool -P named_write_master_zones true

to resolve in this role, in tasks/slave.yml:

  • name: Slave | permit master transfers
    seboolean: name=named_write_master_zones state=yes persistent=yes

but this adds a requirement on the "libsemanage-python" module ;-)

Should this be included in the role, or a pre-requisite outside of the role ?

DNS slave config documentation

When I started using this playbook, even after reading the docs a few times, I was not sure that it would even work with a slave that didn't also do master for some zones. I figured things out by looking at what was in the templates. I thought others might appreciate an example in the docs so I started a branch for that.

While doing that I noticed the table under "Minimal variables..." that lists what is required for master vs slave. It says that bind_zone_domains.name_servers and bind_zone_domains.networks are required for a slave, but it didn't seem to be necessary for me. Am I doing something wrong here or should I correct the docs for that too?

Allow top host to be configured: add an A record for the domain

In my domain, the top of the domain resolves to a webserver. I don't see a way to configure that with this role. In my zone file, the entry is just below the NS entries in the ORIGIN . section, and is unique because it only contains the domain name, not a hostname, like so:

csit.parkland.edu. IN A 216.x.x.x

My current DNS server is ages out of date, and there may be a newer/better way to configure the top host now. Can this role set up a resolution for the domain?

Support SRV records

Hi Bert,

I'd love to see SRV and TXT records be able to be added to the zone file to support Kerberos realm and RedHat IdM/FreeIPA authentication servers.

For example:
; ldap servers
_ldap._tcp IN SRV 0 100 389 hostname

;kerberos realm
_kerberos IN TXT KERBEROS.REALM.NAME

; kerberos servers
_kerberos._tcp IN SRV 0 100 88 hostname
_kerberos._udp IN SRV 0 100 88 hostname
_kerberos-master._tcp IN SRV 0 100 88 hostname
_kerberos-master._udp IN SRV 0 100 88 hostname
_kpasswd._tcp IN SRV 0 100 464 hostname
_kpasswd._udp IN SRV 0 100 464 hostname

;ntp server
_ntp._udp IN SRV 0 100 123 hostname

; CNAME for IPA CA replicas (used for CRL, OCSP)
ipa-ca IN A ip.address

[Enhancement] Querylog

Hi!

First of all, thank you very much for this module.
I think it would be interesting to give the possibility of enabling the log of queries.
I'll make the change and pull the request.

A greeting

Add support for simple forward zones

This could be very useful if forwarding is required only for a specific zone/domain and a Master/Slave configuration would not be possible.
Combine this with allow-query-cache and the bind server will start to take care of most of the required queries minimizing bandwidth and requested to the forward zone.
This is also very useful if the forward zone is private and not known on the Internet.

error: no filter named 'reverse_lookup_zone'

Hi,

Thanks for the work you put into this Ansible playbook :D.

But im running into an issue trying to use it with the Vagrant ansible provisioner the output is as follows

==> ns1: Running provisioner: ansible...

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [ns1]

TASK: [bertvv.bind | Install BIND] ******************************************** 
changed: [ns1] => (item=bind,bind-utils)

TASK: [bertvv.bind | Create serial] ******************************************* 
changed: [ns1]

TASK: [bertvv.bind | Main BIND config file (master)] ************************** 
skipping: [ns1]

TASK: [bertvv.bind | Create forward lookup zone file] ************************* 
skipping: [ns1]

TASK: [bertvv.bind | Create reverse lookup zone file] ************************* 
skipping: [ns1] => (item=192.168.1)
skipping: [ns1] => (item=10.0)

TASK: [bertvv.bind | Main BIND config file (slave)] *************************** 
fatal: [ns1] => {'msg': "AnsibleError: file: /vms/Ansible/ansible/bertvv.bind/templates/slave_etc_named.conf.j2, line number: 64, error: no filter named 'reverse_lookup_zone'", 'failed': True}
fatal: [ns1] => {'msg': "AnsibleError: file: /vms/Ansible/ansible/bertvv.bind/templates/slave_etc_named.conf.j2, line number: 64, error: no filter named 'reverse_lookup_zone'", 'failed': True}

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/root/bind.retry

ns1                        : ok=4    changed=2    unreachable=1    failed=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

My Vagrantfile is as follows,

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|

  config.vm.define "ns1" do |ns1|
    ns1.vm.box = "relativkreativ/centos-7-minimal"
    ns1.vm.hostname = "ns1.setkeh.local"
    ns1.vm.network "private_network", ip: "192.168.33.10"
    ns1.vm.network "public_network", bridge: "bond0"
    ns1.vm.synced_folder "./ansible", "/ansible"
    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "ansible/bind.yml"
    end
  end

  config.vm.define "ns2" do |ns2|
    ns2.vm.box = "relativkreativ/centos-7-minimal"
    ns2.vm.hostname = "ns2.setkeh.local"
    ns2.vm.network "private_network", ip: "192.168.33.11"
    ns2.vm.network "public_network", bridge: "bond0"
    ns2.vm.synced_folder "./ansible", "/ansible"
    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "ansible/bind.yml"
    end
  end
end

and my bind.yml is as follows.


---
- hosts: all
  sudo: true
  vars:
    bind_listen_ipv4:
      - 'any'
    bind_listen_ipv6:
      - 'any'
    bind_allow_query:
      - '192.168.1.0/24'
      - '10.0.0.0/24'
    bind_zone_name: 'setkeh.local'
    bind_zone_networks:
      - '192.168.1'
      - '10.0'
    bind_zone_master_server_ip: '10.0.0.35'
    bind_zone_name_servers:
      - 'ns1'
      - 'ns2'
    bind_zone_mail_servers:
      - name: 'mail'
        preference: '10'
    bind_zone_hosts:
      - name: 'ns1'
        ip: '10.0.0.35'
        aliases:
          - ns1
      - name: 'ns2'
        ip: '10.0.0.36'
        aliases:
          - ns2
      - name: 'web'
        ip: '10.0.0.7'
        aliases:
          - www
  roles:
    - bertvv.bind

If you have any suggestions or idea's as to what i have misconfigured that would be greatly appreciated :)

Thanks.

Is there a way that individual zones can be defined in a separate file?

bind_zone_domain is manageable if you have a small number of zones and a small number of hosts in each zone. It becomes problematic if you have a large number of zones and hosts in each zone. Is there a way to have the zones/hosts defined in separate files to improve manageability?

Add 'dnssec-keygen' for domain

basic script.

#!/bin/bash
mkdir -p /etc/bind/keys/
domain=test.loc
keyfile=/etc/bind/keys/$domain.key

if [ "x$bind_key" = x ]
then
  pushd /etc/bind/keys
  rm -f /etc/bind/keys/K$domain*
  dnssec-keygen -a HMAC-MD5 -b 512 -n HOST $domain.key
  bind_key="$(grep Key: K$domain*.private | cut -d ' ' -f 2)"
  popd
fi
chown root:bind /etc/bind/keys/K$domain*
chmod 640 /etc/bind/keys/K$domain*

how can it be integrated into the playbook to achieve this result?

key "test.loc.key" {
  algorithm hmac-md5;
  secret "WkTF9DYyK4hcboNK1cxHTK/WcFu7di/sdHkwrFJqKBJU YA+08otWNW31g==";
};

zone "test.loc" {
  type master;
  file "test.loc.zone";
  allow-query { any; };
  allow-transfer { none; };
  allow-update { key test.loc.key; };
};

Error when role is skipped by playbook

Hi,

When i skip role in my playbook, your role return an error :/

For fix, just add - skip: true in main.yml :

- name: Source specific variables
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ ansible_distribution }}.yml"
    - "{{ ansible_os_family }}.yml"
    - skip: true
  tags: bind

EDIT : Or not with - skip: true, include_vars its always skipped....

Skipping master.yml

Just faced an issue where the following condition was always failing:

when: ansible_all_ipv4_addresses|last == bind_zone_master_server_ip

My guest is set up so that it has two IP addresses, and the issue was that
ansible_all_ipv4_addresses|last was not referring to the one I set up to be the bind_zone_master_server_ip.

I'm not certain if there are any drawbacks, but what I did was replace the conditional with:

when: bind_zone_master_server_ip not in ansible_all_ipv4_addresses

Network

your example is:
networks:
- '192.0.2'
- '10'
- '172.16'

if network is 172.16.18.0/29 ?
Thanks.

Feature: single entry reverse zones (for AWS Elastic IPs)

Hi Bert,

When I use this role to create reverse zones for my Elastic IPs, I end up with the origin of the full IP address, and then a record for the full IP address. PTR resolution doesn't work unless I remove the IP address from the record.

Maybe the reverse zone template can only insert the non-matching part of the reverse lookup address?

Thanks for an awesome role! I still use it all the time.
Joanna

Add TTL to individual resource records

bind_zone_domains:

  • name: mydomain.com
    hosts:
    • name: pub01
      ip: 192.0.2.1
      ipv6: 2001:db8::1
      ttl: 300
      aliases:
      • name: ns
        ttl: 300
        name_servers:
    • name: ns1
      ttl: 900
      delegate:
    • name: foo
      dns: 192.0.2.1
      ttl: 900
      mail_servers:
    • name: mail
      preference: 10
      ttl: 300

Add support for allow-query-cache

It is very useful to have caching features working for a bind server, this allows the system administrator to use much less bandwidth and queries.

Reload bind instead of restart

After updating configuration file I think we need to reload bind instead of restart? I mean restarting could end up in networking problems for those who's using this DNS server right? If you approve I'd try to submit PR

Notifies sent for localhost and 0.in-addr.arpa

Hi Bert,

When I reload my named service, all our slaves get notified for every zone, including localhost zones. I think this is probably undesirable. It appears that each zone can have "notify no;" added to individual zones. Would it break anything to add this to the localhost zones?

Dec 18 15:14:35 ns2 named[10317]: running
Dec 18 15:14:35 ns2 named[10317]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: sending notifies (serial 0)
Dec 18 15:14:35 ns2 named[10317]: zone 1.0.0.127.in-addr.arpa/IN: sending notifies (serial 0)
Dec 18 15:14:35 ns2 named[10317]: zone 253.125.216.in-addr.arpa/IN: sending notifies (serial 15121813)
Dec 18 15:14:35 ns2 named[10317]: zone 0.in-addr.arpa/IN: sending notifies (serial 0)
Dec 18 15:14:35 ns2 named[10317]: zone localhost.localdomain/IN: sending notifies (serial 0)
Dec 18 15:14:35 ns2 named[10317]: zone 66.162.25.52.in-addr.arpa/IN: sending notifies (serial 15121813)
Dec 18 15:14:35 ns2 named[10317]: zone csit.parkland.edu/IN: sending notifies (serial 15121813)
Dec 18 15:14:35 ns2 named[10317]: zone localhost/IN: sending notifies (serial 0)
Dec 18 15:14:35 ns2 systemd[1]: Started Berkeley Internet Name Domain (DNS).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.