---
- name: Configure named master
  hosts: vm02
  roles:
    - named

  vars:
# Primary Configuration
    named_listen_ipv4:
      - "any"
    named_listen_ipv4_port:
      - 53
    named_listen_ipv6:
      - "::"
    named_listen_ipv6_port:
      - 53
    named_recursion: true
    named_allow_recursion:
      - "Local"
    named_allow_query:
      - "any"
    named_allow_transfer:
      - "Transfer"
    named_dns_keys:
      - name: CertbotKey
        algorithm: hmac-sha512
        secret: as1NQi1QHYX/hAuSR+EbyPYZNgsM2NcTTmSDvPFzkghzUNHAFFSQmabs03gm543vH6X4gYFKXhkzRP2/gQ7nNA==
    named_extra_include_files:
      - "{{ named_auth_file }}"
    named_statistics_channels:
      - named_statistics_host: '127.0.0.1'
      - named_statistics_port: '8053'
      - named_statistics_allow:
          - '127.0.0.1'

    named_acls:
      - name: Transfer
        match_list:
          - 80.211.195.127
      - name: Local
        match_list:
          - 127.0.0.0/8
          - 10.0.0.0/8
          - 172.16.0.0/12
          - 192.168.0.0/16

    named_zones:
      # Primary server for domain gigacoms.info (specify zone type explicitly)
      - name: 'mrwho.ru'
        type: primary
        primaries:
          - 212.60.5.162
        certbot_key: "CertbotKey"
        also_notify:
          - 80.211.195.127
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
#        delegate:
#          - zone: test.gigacoms.info.
#            dns: ns3.gigacoms.info.
#          - zone: test.gigacoms.info.
#            dns: ns4.gigacoms.ru.
        hosts:
          - name: ns1
            ip: 80.211.195.127
          - name: ns2
            ip: 212.60.5.162
          - name: mrwho.ru
            ip: 80.211.195.127
            # ipv6: 2001:db8::1
            aliases:
              - www
          - name: vm01
            ip: 80.211.195.127
            # ipv6: 2001:db8::2
          - name: vm02
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: vpn
            ip: 80.211.195.127
            # ipv6: 2001:db8::d:1
          - name: msk
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: sad
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: tun
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: mptcp
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: ca.local
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: git
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
        mail_servers:
          - name: ASPMX.L.GOOGLE.COM.
            preference: 10
          - name: ALT1.ASPMX.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX2.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX3.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX4.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX5.L.GOOGLE.COM.
            preference: 30
        # services:
        #  - name: _ldap._tcp
        #    weight: 100
        #    port: 88
        #    target: srv010
        # text:
        #  - name: _kerberos
        #    text: KERBEROS.ACME-INC.COM
        #  - name: '@'
        #    text:
        #      - 'some text'
        #      - 'more text'

      - name: 'nimfalida.ru'
        type: primary
        primaries:
          - 212.60.5.162
        allow_update:
          - key "CertbotKey"
        also_notify:
          - 80.211.195.127
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
        hosts:
          - name: nimfalida.ru
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
            aliases: www
        mail_servers:
          - name: mx.yandex.net.
            preference: 10

      - name: 'storagecat.ru'
        type: primary
        primaries:
          - 212.60.5.162
        certbot_key: "CertbotKey"
        also_notify:
          - 80.211.195.127
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
        hosts:
          - name: storagecat.ru.
            ip: 80.211.195.127
            aliases: www
        mail_servers:
          - name: mx.yandex.net.
            preference: 10

      - name: 'astracpa.com'
        type: primary
        primaries:
          - 212.60.5.162
        allow_update:
          - key "CertbotKey"
        also_notify:
          - 80.211.195.127
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
        mail_servers:
          - name: ASPMX.L.GOOGLE.COM.
            preference: 10
          - name: ALT1.ASPMX.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX2.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX3.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX4.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX5.L.GOOGLE.COM.
            preference: 30
        hosts:
          - name: astracpa.com.
            ip: 80.211.195.127
            aliases: www
