Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DDNS keyfile creation, configuration and writeable zone location #59

Merged
merged 6 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ And similarly `zone_my_reverse_inaddr_arpa` and `zone_my_reverse_ip6_arpa` for I

* deploy role to your servers

### DDNS updates

## Key generation

If you want to have your DDNS keys created by this role configure `bind9_generate_ddns_key`:

```yaml
- bind9_generate_ddns_key: true
```

Keys will by default be stored to `files/bind/zones` withinin your playbook location, but you can customize this with `bind9_local_keydir`

```yaml
- bind9_local_keydir: true
0xMattijs marked this conversation as resolved.
Show resolved Hide resolved
```

## Zone database

Please note that for DDNS updates to work, the location of the zone files needs to be writable by the BIND process.
Linux distros with Mandatory Access Control (Apparmor, SELinux) ususally don't allow writing to the default `/etc/bind/zones` path. In order to circumvent this you may want to change the zone files location to `/var/lib/bind/zones` instead:

```yaml
- bind9_zonedir: /var/lib/bind/zones
```

## Dependencies

Expand Down
4 changes: 3 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,6 @@ bind9_log_categories:
- name: lame-servers
destination: 'null'

bind9_zonedir: /var/lib/bind/zones
bind9_generate_ddns_key: true
bind9_zonedir: /etc/bind/zones
bind9_local_keydir: files/bind/zones
6 changes: 3 additions & 3 deletions tasks/create_ddns_keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
become: false
delegate_to: localhost
stat:
path: bind/zones/{{ item.update_keyfile }}.private
path: "{{ bind9_local_keydir }}/{{ item.update_keyfile }}.private"
register: update_keyfile_tmp
when: item.update_keyfile is defined

Expand All @@ -16,14 +16,14 @@
- name: copy DDNS key to control host
fetch:
src: "/etc/bind/keys/{{ item.update_keyfile }}.private"
dest: bind/zones/{{ item.update_keyfile }}.private
dest: "{{ bind9_local_keydir }}/{{ item.update_keyfile }}.private"
flat: true
when: ddns_key.changed

- name: create dummy DDNS public key file on control host
become: false
delegate_to: localhost
file:
path: bind/zones/{{ item.update_keyfile }}.key
path: "{{ bind9_local_keydir }}/{{ item.update_keyfile }}.key"
state: touch
when: ddns_key.changed
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- include_tasks: create_ddns_keys.yml
with_items:
- "{{ bind9_zones_static + bind9_zones_dynamic }}"
when: bind9_generate_ddns_key | bool

- name: Configure bind9 named.conf files
template:
Expand Down