linting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
vincent 2021-10-22 10:53:28 +02:00
parent 15412df235
commit be1bffbd4d
11 changed files with 96 additions and 105 deletions

View File

@ -107,47 +107,47 @@ This release adds support for multiple TXT entries and fixes some bugs.
### Changed ### Changed
* The call to `named-checkconf` was fixed. It had the full path to the binary, which is not the same on all distributions. (GH-20, credit @peterjanes) - The call to `named-checkconf` was fixed. It had the full path to the binary, which is not the same on all distributions. (GH-20, credit @peterjanes)
## 3.5.1 - 2016-09-22 ## 3.5.1 - 2016-09-22
### Changed ### Changed
* The check for master/slave server is improved (GH-19, credit @josetaas) - The check for master/slave server is improved (GH-19, credit @josetaas)
## 3.5.0 - 2016-07-28 ## 3.5.0 - 2016-07-28
### Added ### Added
* Introduced role variable `bind_log`, the path to the log file. - Introduced role variable `bind_log`, the path to the log file.
* Introduced role variable `bind_zone_also_notify`, a list of servers that will receive a notification when the master zone file is reloaded (GH-18, credit: Joanna Delaporte) - Introduced role variable `bind_zone_also_notify`, a list of servers that will receive a notification when the master zone file is reloaded (GH-18, credit: Joanna Delaporte)
* Reverse zone files now handle the case with only a single host (GH-18, credit: Joanna Delaporte) - Reverse zone files now handle the case with only a single host (GH-18, credit: Joanna Delaporte)
## 3.4.0 - 2016-05-26 ## 3.4.0 - 2016-05-26
### Added ### Added
* (GH-16) Support for service record (SRV) lookups - (GH-16) Support for service record (SRV) lookups
* Support for text record (TXT) lookups - Support for text record (TXT) lookups
### Changed ### Changed
* Fixed Ansible 2.0 deprecation warnings - Fixed Ansible 2.0 deprecation warnings
* Generating a serial is no longer considered a change - Generating a serial is no longer considered a change
* Ensured that all role variables have a default value, e.g. empty list instead of undefined. This simplifies template logic (no `if defined` tests), and is considered [deprecated in playbooks within a *with_* loop](https://docs.ansible.com/ansible/porting_guide_2.0.html#deprecated). - Ensured that all role variables have a default value, e.g. empty list instead of undefined. This simplifies template logic (no `if defined` tests), and is considered [deprecated in playbooks within a _with\__ loop](https://docs.ansible.com/ansible/porting_guide_2.0.html#deprecated).
## 3.3.1 - 2016-04-08 ## 3.3.1 - 2016-04-08
### Removed ### Removed
* The `version:` field in `meta/main.yml`. This an unofficial field that is used by a third-party tool for managing role dependencies (librarian-ansible). Custom meta fields are no longer accepted in Ansible 2.0. See [ansible/ansible#13496](https://github.com/ansible/ansible/issues/13496) for more info. Unfortunately, this will break support for librarian-ansible. As a workaround, until this issue is resolved upstream, use version 3.3.0 of this role. - The `version:` field in `meta/main.yml`. This an unofficial field that is used by a third-party tool for managing role dependencies (librarian-ansible). Custom meta fields are no longer accepted in Ansible 2.0. See [ansible/ansible#13496](https://github.com/ansible/ansible/issues/13496) for more info. Unfortunately, this will break support for librarian-ansible. As a workaround, until this issue is resolved upstream, use version 3.3.0 of this role.
## 3.3.0 - 2016-04-08 ## 3.3.0 - 2016-04-08
### Added ### Added
* Added role variable `bind_other_name_servers` for adding NS records for DNS servers outside of the domain. (GH-12) - Added role variable `bind_other_name_servers` for adding NS records for DNS servers outside of the domain. (GH-12)
* Re-added `bind_recursion`, as it is needed in some cases. (GH-14) - Re-added `bind_recursion`, as it is needed in some cases. (GH-14)
### Removed ### Removed
@ -155,52 +155,52 @@ This release adds support for multiple TXT entries and fixes some bugs.
### Added ### Added
* The domain name can now also point to an IP address, enabling e.g. "http://example.com/" (GH-11) - The domain name can now also point to an IP address, enabling e.g. "http://example.com/" (GH-11)
## 3.2.0 - 2015-12-07 ## 3.2.0 - 2015-12-07
### Added ### Added
* Add support for multiple IP addresses per host (GH-9) - Add support for multiple IP addresses per host (GH-9)
* Allow setting `rrset-order` (for DNS round robin) - Allow setting `rrset-order` (for DNS round robin)
* Add support for (multiple) IPv6 (AAAA) records (GH-2). For now, only forward lookups are supported. - Add support for (multiple) IPv6 (AAAA) records (GH-2). For now, only forward lookups are supported.
### Changed ### Changed
* Test code is put into a separate branch. This means that test code is no longer included when installing the role from Ansible Galaxy. - Test code is put into a separate branch. This means that test code is no longer included when installing the role from Ansible Galaxy.
## 3.1.0 - 2015-12-04 ## 3.1.0 - 2015-12-04
### Added ### Added
* Add support for zone transfers (GH-8) - Add support for zone transfers (GH-8)
* Check whether `bind_zone_master_server_ip` was set (GH-7) - Check whether `bind_zone_master_server_ip` was set (GH-7)
### Removed ### Removed
* Role variable `bind_recursion` was removed. This role is explicitly only suitable for an authoritative DNS server, and in this case, recursion should be off. - Role variable `bind_recursion` was removed. This role is explicitly only suitable for an authoritative DNS server, and in this case, recursion should be off.
## 3.0.0 - 2015-06-14 ## 3.0.0 - 2015-06-14
### Added ### Added
* You can now set up a master and slave DNS server. - You can now set up a master and slave DNS server.
* The variable `bind_zone_master_server_ip` was added. This is a **required** variable, which makes this release not backwards compatible. - The variable `bind_zone_master_server_ip` was added. This is a **required** variable, which makes this release not backwards compatible.
* Automated acceptance tests for the test playbook - Automated acceptance tests for the test playbook
## 2.0.0 - 2015-06-10 ## 2.0.0 - 2015-06-10
### Added ### Added
* Added EL6 to supported platforms. Thanks to @rilindo for verifying this. - Added EL6 to supported platforms. Thanks to @rilindo for verifying this.
### Changed ### Changed
* Recursion is turned off by default, which fits an authoritative name server. This change is not backwards compatible, as the behaviour of BIND is different from before when you do not set the variable `bind_recursion` explicitly. - Recursion is turned off by default, which fits an authoritative name server. This change is not backwards compatible, as the behaviour of BIND is different from before when you do not set the variable `bind_recursion` explicitly.
### Removed ### Removed
* Firewall settings. This should not be a concern of this role. Configuring the firewall is functionality offered by other roles (e.g. [bertvv.bind](https://github.com/bertvv/ansible-role-el7)) - Firewall settings. This should not be a concern of this role. Configuring the firewall is functionality offered by other roles (e.g. [bertvv.bind](https://github.com/bertvv/ansible-role-el7))
## 1.0.0 - 2015-04-22 ## 1.0.0 - 2015-04-22
@ -210,4 +210,3 @@ First release!
- Functionality for master DNS server - Functionality for master DNS server
- Multiple reverse lookup zones - Multiple reverse lookup zones

View File

@ -10,7 +10,7 @@ An Ansible role for setting up BIND ISC as an **authoritative-only** DNS server
- slave server - slave server
- set up forward and reverse lookup zone files - 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. 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.
Configuring the firewall is not a concern of this role, so you should do this using another role (e.g. [bertvv.rh-base](https://galaxy.ansible.com/bertvv/rh-base/)). Configuring the firewall is not a concern of this role, so you should do this using another role (e.g. [bertvv.rh-base](https://galaxy.ansible.com/bertvv/rh-base/)).
@ -27,7 +27,7 @@ See the [change log](CHANGELOG.md) for notable changes between versions.
Variables are not required, unless specified. Variables are not required, unless specified.
| Variable | Default | Comments (type) | | Variable | Default | Comments (type) |
| :--- | :--- | :--- | | :--------------------------- | :------------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
| `bind_acls` | `[]` | A list of ACL definitions, which are dicts with fields `name` and `match_list`. See below for an example. | | `bind_acls` | `[]` | A list of ACL definitions, which are dicts with fields `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_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_allow_recursion` | `['any']` | Similar to bind_allow_query, this option applies to recursive queries. |
@ -73,12 +73,12 @@ Variables are not required, unless specified.
Even though only variable `bind_zone_master_server_ip` is required for the role to run without errors, this is not sufficient to get a working zone. In order to set up an authoritative name server that is available to clients, you should also at least define the following variables: Even though only variable `bind_zone_master_server_ip` is required for the role to run without errors, this is not sufficient to get a working zone. In order to set up an authoritative name server that is available to clients, you should also at least define the following variables:
| Variable | Master | Slave | | Variable | Master | Slave |
| :--- | :---: | :---: | | :------------------ | :----: | :---: |
| `bind_zone_domains` | V | V | | `bind_zone_domains` | V | V |
| ` - name` | V | V | | `- name` | V | V |
| ` - networks` | V | -- | | `- networks` | V | -- |
| ` - name_servers` | V | -- | | `- name_servers` | V | -- |
| ` - hosts` | V | -- | | `- hosts` | V | -- |
| `bind_listen_ipv4` | V | V | | `bind_listen_ipv4` | V | V |
| `bind_allow_query` | V | V | | `bind_allow_query` | V | V |
@ -132,7 +132,7 @@ bind_zone_domains:
Host names that this DNS server should resolve can be specified in `hosts` as a list of dicts with fields `name`, `ip` and `aliases` Host names that this DNS server should resolve can be specified in `hosts` as a list of dicts with fields `name`, `ip` and `aliases`
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. 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_zone_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](http://www.zytrax.com/books/dns/ch9/rr.html), a simple load balancing technique. The order in which the IP addresses are returned can be configured with role variable `bind_rrset_order`. If you want to specify multiple IP addresses for a host, add entries to `bind_zone_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](http://www.zytrax.com/books/dns/ch9/rr.html), a simple load balancing technique. The order in which the IP addresses are returned can be configured with role variable `bind_rrset_order`.
@ -148,7 +148,7 @@ Based on the idea and examples detailed at <https://linuxmonk.ch/wordpress/index
To delegate a zone to a DNS, it is enough to create a `NS` record (under delegate) which is the equivalent of: To delegate a zone to a DNS, it is enough to create a `NS` record (under delegate) which is the equivalent of:
``` ```dns
foo IN NS 192.0.2.1 foo IN NS 192.0.2.1
``` ```
@ -189,7 +189,7 @@ There are two test environments for this role, one based on Vagrant, the other o
The script `docker-tests.sh` will create a Docker container, and apply this role from a playbook `test.yml`. The Docker images are configured for testing Ansible roles and are published at <https://hub.docker.com/r/bertvv/ansible-testing/>. There are images available for several distributions and versions. The distribution and version should be specified outside the script using environment variables: The script `docker-tests.sh` will create a Docker container, and apply this role from a playbook `test.yml`. The Docker images are configured for testing Ansible roles and are published at <https://hub.docker.com/r/bertvv/ansible-testing/>. There are images available for several distributions and versions. The distribution and version should be specified outside the script using environment variables:
``` ```dns
DISTRIBUTION=centos VERSION=7 ./docker-tests/docker-tests.sh DISTRIBUTION=centos VERSION=7 ./docker-tests/docker-tests.sh
``` ```
@ -197,7 +197,7 @@ The specific combinations of distributions and versions that are supported by th
The first time the test script is run, a container will be created that is assigned the IP address 172.17.0.2. This will be the master DNS-server. The server is still running after the script finishes and can be queried from the command line, e.g.: The first time the test script is run, a container will be created that is assigned the IP address 172.17.0.2. This will be the master DNS-server. The server is still running after the script finishes and can be queried from the command line, e.g.:
``` ```sh
$ dig @172.17.0.2 www.acme-inc.com +short $ dig @172.17.0.2 www.acme-inc.com +short
srv001.acme-inc.com. srv001.acme-inc.com.
172.17.1.1 172.17.1.1
@ -205,7 +205,7 @@ srv001.acme-inc.com.
If you run the script again, a new container is launched with IP address 172.17.0.3 that will be set up as a slave DNS-server. After a few seconds, it will have received updates from the master server and can be queried as well. If you run the script again, a new container is launched with IP address 172.17.0.3 that will be set up as a slave DNS-server. After a few seconds, it will have received updates from the master server and can be queried as well.
``` ```ShellSession
$ dig @172.17.0.3 www.acme-inc.com +short $ dig @172.17.0.3 www.acme-inc.com +short
srv001.acme-inc.com. srv001.acme-inc.com.
172.17.1.1 172.17.1.1
@ -213,7 +213,7 @@ srv001.acme-inc.com.
The script `docker-tests/functional-tests.sh` will run a [BATS](https://github.com/sstephenson/bats) test suite, `dns.bats` that performs a number of different queries. Specify the server IP address as the environment variable `${SUT_IP}` (short for System Under Test). The script `docker-tests/functional-tests.sh` will run a [BATS](https://github.com/sstephenson/bats) test suite, `dns.bats` that performs a number of different queries. Specify the server IP address as the environment variable `${SUT_IP}` (short for System Under Test).
``` ```ShellSession
$ SUT_IP=172.17.0.2 ./docker-tests/functional-tests.sh $ SUT_IP=172.17.0.2 ./docker-tests/functional-tests.sh
### Using BATS executable at: /usr/local/bin/bats ### Using BATS executable at: /usr/local/bin/bats
### Running test /home/bert/CfgMgmt/roles/bind/tests/dns.bats ### Running test /home/bert/CfgMgmt/roles/bind/tests/dns.bats
@ -238,10 +238,10 @@ $ SUT_IP=172.17.0.3 ./docker-tests/functional-tests.sh
3. `cd vagrant-tests/` 3. `cd vagrant-tests/`
4. `vagrant up` will then create two VMs and apply a test playbook (`test.yml`). 4. `vagrant up` will then create two VMs and apply a test playbook (`test.yml`).
The command `vagrant up` results in a setup with *two* DNS servers, a master and a slave, set up according to playbook `test.yml`. The command `vagrant up` results in a setup with _two_ DNS servers, a master and a slave, set up according to playbook `test.yml`.
| **Hostname** | **ip** | | **Hostname** | **ip** |
| :--- | :--- | | :--------------- | :------------ |
| `testbindmaster` | 192.168.56.53 | | `testbindmaster` | 192.168.56.53 |
| `testbindslave` | 192.168.56.54 | | `testbindslave` | 192.168.56.54 |

View File

@ -1,6 +1,5 @@
# roles/bind/defaults/main.yml # roles/bind/defaults/main.yml
--- ---
bind_log: "data/named.run" bind_log: "data/named.run"
bind_zone_domains: bind_zone_domains:

View File

@ -1,6 +1,5 @@
# roles/bind/handlers/main.yml # roles/bind/handlers/main.yml
--- ---
- name: reload bind - name: reload bind
service: service:
name: "{{ bind_service }}" name: "{{ bind_service }}"

View File

@ -1,6 +1,7 @@
--- ---
galaxy_info: galaxy_info:
author: Bert Van Vreckem author: Bert Van Vreckem
role_name: dns
description: Sets up ISC BIND on RHEL/CentOS 6/7, Ubuntu 16.04/18.04 LTS (Xenial/Bionic), or Arch Linux as an authoritative DNS server for one or more domains (master and/or slave). description: Sets up ISC BIND on RHEL/CentOS 6/7, Ubuntu 16.04/18.04 LTS (Xenial/Bionic), or Arch Linux as an authoritative DNS server for one or more domains (master and/or slave).
license: BSD license: BSD
min_ansible_version: 2.7 min_ansible_version: 2.7

View File

@ -1,6 +1,5 @@
# roles/bind/tasks/main.yml # roles/bind/tasks/main.yml
--- ---
# Initialise distribution-specific variables # Initialise distribution-specific variables
- name: Source specific variables - name: Source specific variables
include_vars: "{{ item }}" include_vars: "{{ item }}"
@ -57,9 +56,8 @@
with_items: with_items:
- "{{ forward_hashes_temp.results }}" - "{{ forward_hashes_temp.results }}"
- name: Read reverse ipv4 zone hashes - name: Read reverse ipv4 zone hashes
shell: "grep -s \"^; Hash:\" {{ bind_zone_dir }}/{{ ('.'.join(item.1.replace(item.1+'.','').split('.')[::-1])) }}.in-addr.arpa || true" shell: 'grep -s "^; Hash:" {{ bind_zone_dir }}/{{ (''.''.join(item.1.replace(item.1+''.'','''').split(''.'')[::-1])) }}.in-addr.arpa || true'
changed_when: false changed_when: false
check_mode: false check_mode: false
register: reverse_hashes_temp register: reverse_hashes_temp
@ -77,7 +75,7 @@
- item - item
- name: Read reverse ipv6 zone hashes - name: Read reverse ipv6 zone hashes
shell: "grep -s \"^; Hash:\" {{ bind_zone_dir }}/{{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }} || true" shell: 'grep -s "^; Hash:" {{ bind_zone_dir }}/{{ (item.1 | ipaddr(''revdns''))[-(9+(item.1|regex_replace(''^.*/'','''')|int)//2):-1] }} || true'
changed_when: false changed_when: false
check_mode: false check_mode: false
register: reverse_hashes_ipv6_temp register: reverse_hashes_ipv6_temp

View File

@ -1,16 +1,15 @@
# roles/bind/tasks/master.yml # roles/bind/tasks/master.yml
# Set up a BIND master server # Set up a BIND master server
--- ---
- name: Master | Main BIND config file (master) - name: Master | Main BIND config file (master)
template: template:
src: master_etc_named.conf.j2 src: master_etc_named.conf.j2
dest: "{{ bind_config }}" dest: "{{ bind_config }}"
owner: "{{ bind_owner }}" owner: "{{ bind_owner }}"
group: "{{ bind_group }}" group: "{{ bind_group }}"
mode: '0640' mode: "0640"
setype: named_conf_t setype: named_conf_t
validate: 'named-checkconf %s' validate: "named-checkconf %s"
notify: reload bind notify: reload bind
tags: bind tags: bind
@ -22,7 +21,7 @@
group: "{{ bind_group }}" group: "{{ bind_group }}"
mode: "{{ bind_zone_file_mode }}" mode: "{{ bind_zone_file_mode }}"
setype: named_zone_t setype: named_zone_t
validate: 'named-checkzone -d {{ item.name }} %s' validate: "named-checkzone -d {{ item.name }} %s"
with_items: with_items:
- "{{ bind_zone_domains }}" - "{{ bind_zone_domains }}"
notify: reload bind notify: reload bind
@ -48,7 +47,7 @@
- name: Master | Create reverse IPv6 lookup zone file - name: Master | Create reverse IPv6 lookup zone file
template: template:
src: reverse_zone_ipv6.j2 src: reverse_zone_ipv6.j2
dest: "{{bind_zone_dir}}/{{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }}" dest: "{{ bind_zone_dir }}/{{ (item.1 | ipaddr('revdns'))[-(9+(item.1|regex_replace('^.*/','')|int)//2):-1] }}"
owner: "{{ bind_owner }}" owner: "{{ bind_owner }}"
group: "{{ bind_group }}" group: "{{ bind_group }}"
mode: "{{ bind_zone_file_mode }}" mode: "{{ bind_zone_file_mode }}"

View File

@ -1,15 +1,14 @@
# roles/bind/tasks/master.yml # roles/bind/tasks/master.yml
# Set up a BIND slave server # Set up a BIND slave server
--- ---
- name: Slave | Main BIND config file (slave) - name: Slave | Main BIND config file (slave)
template: template:
src: slave_etc_named.conf.j2 src: slave_etc_named.conf.j2
dest: "{{ bind_config }}" dest: "{{ bind_config }}"
owner: "{{ bind_owner }}" owner: "{{ bind_owner }}"
group: "{{ bind_group }}" group: "{{ bind_group }}"
mode: '0640' mode: "0640"
setype: named_conf_t setype: named_conf_t
validate: 'named-checkconf %s' validate: "named-checkconf %s"
notify: reload bind notify: reload bind
tags: bind tags: bind

View File

@ -1,6 +1,5 @@
# roles/bind/vars/RedHat.yml # roles/bind/vars/RedHat.yml
--- ---
bind_packages: bind_packages:
- python-netaddr - python-netaddr
- bind - bind

View File

@ -1,6 +1,5 @@
# roles/bind/vars/Debian.yml # roles/bind/vars/Debian.yml
--- ---
bind_packages: bind_packages:
- python-netaddr - python-netaddr
- bind9 - bind9

View File

@ -1,6 +1,5 @@
# roles/bind/vars/RedHat.yml # roles/bind/vars/RedHat.yml
--- ---
bind_packages: bind_packages:
- python-netaddr - python-netaddr
- bind - bind