Giter Site home page Giter Site logo

ansible-role-unbound's Introduction

ansible-role-unbound

Ansible role for Unbound DNS Server and resolver

Supports

  • Add DNS entries (multiple record types per entry)
  • Generation of DNS entries from ansible inventory (A entries and reverse)
  • Forward to another dns
  • IPv4/IPv6 for reverse

Information :

  • Tested on Ubuntu
  • Tested on Debian Stretch (Use forward-ssl-upstream instead of forward-tls-upstream)
  • Untested on Fedora

Example :

Simple forward on localhost :

# Activate forward (active by default)
unbound_forward_zone_active : true
# Activate DNS over TLS (active by default)
unbound_forward_zone_configuration:
    - forward-ssl-upstream: "yes" # `forward-ssl-upstream` for old version
# Forward server to Cloudflare DNS
unbound_forward_zone:
   - "1.1.1.1@853#cloudflare-dns.com"
   - "1.0.0.1@853#cloudflare-dns.com"

Generate entries and reverse from the inventory (need ansible_ssh_host set on all host)

# Listen interface
unbound_interfaces:
    - 127.0.0.1
    - 192.168.0.10

# Authorized IPs
unbound_access_control:
    - 127.0.0.1 allow
    - 192.168.0.0/24 allow

# Create entries from inventory (reverse also created by default)
unbound_inventory_domain:
    all: 'internal.domain' # All hosts

# Create reverse entries from inventory
unbound_inventory_reverse_domain:
    all: 'internal.domain' # All hosts

# Activate forward (active by default)
unbound_forward_zone_active: true
# Activate DNS over TLS (active by default)
unbound_forward_zone_configuration:
    - forward-tls-upstream: "yes" # `forward-ssl-upstream` for old version
# Forward server to Cloudflare DNS
unbound_forward_zone:
   - "1.1.1.1@853#cloudflare-dns.com"
   - "1.0.0.1@853#cloudflare-dns.com"

More complete example (need ansible_ssh_host set on all host)

# Listen interface
unbound_interfaces:
    - 127.0.0.1
    - 192.168.0.10

# Authorized IPs
unbound_access_control:
    - 127.0.0.1 allow
    - 192.168.0.0/24 allow

# Simple DNS entries
unbound_domains:
    - domain_name: "example.com"
      host1: IN A 127.0.0.1
      www: IN CNAME host1

# Create entry and reverse
unbound_domains_with_reverses:
    - domain_name: "reversed.example.com"
      host1: 127.0.0.1
      host2: 127.0.0.2
      host3: 127.0.0.3

# Create entries from inventory
unbound_inventory_domain:
    all: 'localdomain' # All hosts
    webserver: 'webserver.localdomain' # Hosts in webserver

# Create reverse entries from inventory
unbound_inventory_reverse_domain:
    dbserver: 'dbserver.localdomain' # Hosts in dbserver
    webserver: 'webserver.localdomain' # Hosts in webserver

# Type of local host (default : static )
unbound_local_zone_type:
    example.com: "transparent"
    reversed.example.com: "static"

Create local domain data

For creating local domain data with the unbound_domain variable two variants can be used. The simple one uses plain strings to create one resource record per host name. With this variant no other resource records for the same name can be created.

The more complex version allows dict objects to set the following resource records: A, AAAA, CNAME, TXT. Reverse records are automatically created for A and AAAA if needed.

Resource records for the domain itself may be set as a list with the domain_rr key. Attention - the domain name is not automatically added, the string is taken as is!

Example for simple domain:
unbound_domain:
  domain_name: example.net
  domain_rr:
    - "MX 10 server1.example.net."
    - "IN A 1.2.3.5"
  www: "1.2.3.4"
  server1: "IN A 1.2.3.5"
  admin-contact: 'IN TXT "ask your neighbour"'

Generated unbound configuration:

    local-zone: "example.net." static
    local-data: "example.net. MX 10 server1.example.net."
    local-data: "example.net. IN A 1.2.3.5"
    local-data: "www.example.net. 1.2.3.4"
    local-data: "server1.example.net. IN A 1.2.3.5"
    local-data: 'admin-contact.example.net. IN TXT "ask your neighbour"'
Example for complex domain:

All fields (ip, ipv6, cnames, txt, reverse) are optional, only the attributes needed should be set

unbound_domain:
  domain_name: example.net
  www:
    ip: "1.2.3.4"
    reverse: true
  server1:
    ip: "1.2.3.5"
    ipv6: "fe80::7"
    cnames:
      - mail
      - imap
      - smtp
    reverse: true
  admin-contact:
    txt: "ask your neighbour"

Generated unbound configuration:

    local-zone: "example.net." static
    local-data: "www.example.net. 1.2.3.4"
    local-data-ptr: "1.2.3.4 www.example.net."
    local-data: "server1.example.net. IN A  1.2.3.5"
    local-data: "server1.example.net. IN AAAA fe80::7"
    local-data: "mail.example.net. IN CNAME server1.example.net."
    local-data: "imap.example.net. IN CNAME server1.example.net."
    local-data: "smtp.example.net. IN CNAME server1.example.net."
    local-data-ptr: "1.2.3.5 server1.example.net."
    local-data-ptr: "fe80::7 server1.example.net."
    local-data: 'admin-contact.example.net. IN TXT "ask your neighbour"'
Example for mixed domain with both versions:
unbound_domain:
  domain_name: example.net
  www: "1.2.3.4"
  server1:
    ip: "1.2.3.5"
    ipv6: "fe80::7"
    cnames:
      - mail
      - imap
      - smtp
    reverse: true

Generated unbond configuration:

    local-zone: "example.net." static
    local-data: "www.example.net. 1.2.3.4"
    local-data: "server1.example.net. IN A  1.2.3.5"
    local-data: "server1.example.net. IN AAAA fe80::7"
    local-data: "mail.example.net. IN CNAME server1.example.net."
    local-data: "imap.example.net. IN CNAME server1.example.net."
    local-data: "smtp.example.net. IN CNAME server1.example.net."
    local-data-ptr: "1.2.3.5 server1.example.net."
    local-data-ptr: "fe80::7 server1.example.net."

ansible-role-unbound's People

Contributors

brianclemens avatar jdauphant avatar sseide avatar towo avatar webspider 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

Watchers

 avatar  avatar  avatar  avatar  avatar

ansible-role-unbound's Issues

failed to validate

fatal: [10.10.10.14]: FAILED! => {"changed": false, "checksum": "366f4456943dd3cc28e67389042828720f38f5aa", "exit_status": 1, "msg": "failed to validate", "stderr": "[1515792263] unbound-checkconf[9103:0] fatal error: config file /home/vagrant/.ansible/tmp/ansible-tmp-1515792263.28-258574223960139/source is not inside chroot /etc/unbound\n", "stderr_lines": ["[1515792263] unbound-checkconf[9103:0] fatal error: config file /home/vagrant/.ansible/tmp/ansible-tmp-1515792263.28-258574223960139/source is not inside chroot /etc/unbound"], "stdout": "", "stdout_lines": []}```

new version 1.3 not available via Ansible-Galaxy

The new version "1.3" cannot be installed via "ansible-galaxy" Latest version there is "1.2".
This is the version installed with plain "ansible-galaxy install jdauphant.unbound". Explict request version "1.3" with requirements.yml file gives error.

Check with:

curl 'https://galaxy.ansible.com/api/v1/roles/?owner__username=jdauphant&name=unbound' | jq .results[0].summary_fields.versions

Output of availabe Versions:

[
  {
    "release_date": "2014-08-29T16:17:30Z",
    "id": 2944,
    "name": "v1.0.0"
  },
  {
    "release_date": "2015-01-14T11:38:09Z",
    "id": 2979,
    "name": "v1.0.1"
  },
  {
    "release_date": "2017-06-13T22:05:55Z",
    "id": 33279,
    "name": "v1.0.2"
  },
  {
    "release_date": "2017-10-06T14:25:57Z",
    "id": 39698,
    "name": "v1.0.3"
  },
  {
    "release_date": "2018-04-15T10:32:12Z",
    "id": 56864,
    "name": "v1.2"
  }
]

But checking the Galaxy info page at https://galaxy.ansible.com/jdauphant/unbound shows as "Last commit" / "Last import" 19 days ago, therefor version 1.3 should be available...

Seems to happen from time to time (e.g. ansiblebit/oracle-java#39). May need action from Ansible company itself.

Create special records in zone file

Hello,
I need to create a record like this in the zone file :

    local-zone: "ldap.uman-it.fr." static
    local-data: "ldap.uman-it.fr. IN A 10.1.2.2"
    local-data-ptr: "10.1.2.2 ldap.uman-it.fr"

Note: the it's the subdomain+domain in the 3 lines

If I use unbound_domains_with_reverses variable like this :

unbound_domains_with_reverses:
    - domain_name: "uman-it.fr"
      ldap: 10.1.2.2

It didn't do the trick.

I also tried :

unbound_domains_with_reverses:
    - domain_name: "ldap.uman-it.fr"
      "": 10.1.2.2

Is it possible ?

Thanks for all

Task "Ensure log file exist " restarts service always.

  • name: Ensure log file exist
    file: path={{unbound_logfile}} state=touch mode=755 owner=unbound
    notify: restart unbound
    tags: ["configuration","unbound"]

when using state=touch, task status will be change:true always, so better use state=file in that case unbound will not restarted when {{unbound_logfile}} is exists.

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.