---
- 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-sha256
        secret: "YCUScDPbF9bscPFB0mLzRr2/V54FB7tcrifAdrrnlBI="
    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.1
          - 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 mrhwo.ru (specify zone type explicitly)
      - name: 'mrwho.ru'
        type: primary
        certbot_key: "CerbotKey"
        also_notify:
          - 80.211.195.127
        primaries:
          - 212.60.5.162
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
#        delegate:
#          - zone: local.mrwho.ru.
#            dns: 172.20.21.100
#          - zone: local.mrwho.ru.
#            dns: ns2.mrwho.ru.
        mail_servers:
          - name: ASPMX.L.GOOGLE.COM.
            preference: 10
          - name: ALT1.ASPMX.L.GOOGLE.COM.
            preference: 20
          - name: ALT2.ASPMX.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX2.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX3.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX4.L.GOOGLE.COM.
            preference: 30
          - name: ASPMX5.L.GOOGLE.COM.
            preference: 30

        hosts:
          - name: mrwho.ru.
            ip: 80.211.195.127
          - name: ns1
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
          - name: ns2
            ip: 80.211.195.127
          - name: vm01
            ip: 80.211.195.127
            aliases:
              - proxy
              - vpn
              - www
          - name: vm02
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
            aliases:
              - msk
              - sad
              - tun
              - mptcp
              - ca.local
#      - name: 'local.mrwho.ru'
#        type: primary
#        certbot_key: "CerbotKey"
#        also_notify:
#          - 80.211.195.127
#          - 172.20.21.100
#        primaries:
#          - 172.20.21.100
#          - 212.60.5.162
#        name_servers:
#          - ns1.mrwho.ru.
#          - ns2.mrwho.ru.
#        hosts:
#          - name: 'local.mrwho.ru.'
#            ip: 172.20.21.1
#          - name: ca
#            ip: 172.20.21.99
#          - name: router
#            ip: 172.20.21.100
#          - name: opensearch
#            ip: 172.20.21.101
#          - name: uyuni
#            ip: 172.20.21.102
#          - name: vault
#            ip: 172.20.21.103
#          - name: gitlab
#            ip: 172.20.21.104

      # Primary server for domain nimfalida.ru (specify zone type explicitly)
      - name: 'nimfalida.ru'
        type: primary
        certbot_key: "CerbotKey"
        also_notify:
          - 80.211.195.127
        primaries:
          - 212.60.5.162
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
        mail_servers:
          - name: mx.yandex.net.
            preference: 10
        hosts:
          - name: nimfalida.ru.
            ip: 212.60.5.162
            ipv6: 2a00:b700:3::286
            aliases:
              - www

      # Primary server for domain storagecat.ru (specify zone type explicitly)
      - name: 'storagecat.ru'
        type: primary
        certbot_key: "CerbotKey"
        also_notify:
          - 80.211.195.127
        primaries:
          - 212.60.5.162
        name_servers:
          - ns1.mrwho.ru.
          - ns2.mrwho.ru.
        mail_servers:
          - name: mx.yandex.net.
            preference: 10

        hosts:
          - name: storagecat.ru.
            ip: 80.211.195.127
            aliases:
              - www

      # Primary server for domain astracpa.com (specify zone type explicitly)
      - name: 'astracpa.com'
        type: primary
        certbot_key: "CerbotKey"
        also_notify:
          - 80.211.195.127
        primaries:
          - 212.60.5.162
        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: ALT2.ASPMX.L.GOOGLE.COM.
            preference: 20
          - name: ASPMX2.L.GOOGLE.COM.
            preference: 30
          - 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
