Enhancement: Structure

This commit is contained in:
Stupéflo 2024-05-17 19:10:03 +02:00
parent ea74e0b246
commit 8d2035b405
Signed by: stupeflo
GPG key ID: 873D883BD359DEE2
5 changed files with 20 additions and 18 deletions

View file

@ -1,9 +1,5 @@
- name: Configuration of ns zones
hosts: primarydns
vars:
zones:
- zome:
domain_name: trans13nrv.eu.org
tasks:
- name: Use variables
@ -25,19 +21,19 @@
state: directory
owner: "{{ root.user }}"
group: "{{ dns.group }}"
mode: "660"
mode: "775"
- name: Ensure required keys zone directory is present
ansible.builtin.file:
path: "{{ dns.paths.keys }}"
path: "{{ dns.paths.keys_dir }}"
state: directory
owner: "{{ dns.user }}"
group: "{{ dns.group }}"
mode: "660"
mode: "770"
- name: Prymary Zones
ansible.builtin.include_tasks: tasks/ns/primary-zone.yml
loop: "{{ zones }}"
with_list: "{{ dns.zones }}"
- name: Reload bind9 service
ansible.builtin.service:

View file

@ -1,22 +1,25 @@
---
- vars:
zone_config_file: "{{ dns.patch.etc }}/named.conf.{{ zone.domain_name }}"
zone_db_file: "{{ dns.patch.primary_zones }}/db.{{ zone.domain_name }}.zone"
- name: "Setting facts for zone {{ item.zone.domain_name }}"
ansible.builtin.set_fact:
zone_config_file: "{{ dns.paths.etc }}/named.conf.{{ item.zone.domain_name }}"
zone_db_file: "{{ dns.paths.primary_zones }}/db.{{ item.zone.domain_name }}.zone"
domain_name: "{{ item.zone.domain_name }}"
- name: Updating primary zone db file
ansible.builtin.file:
src: "file/ns/zone/db.{{ zone.domain_name }}"
ansible.builtin.copy:
src: "tasks/ns/files/db.{{ domain_name }}.zone"
dest: "{{ zone_db_file }}"
mode: "644"
- name: "Creating zone {{ domain_name }}"
ansible.builtin.template:
src: templates/ns/zone/named.conf.primary-zone.j2
src: tasks/ns/templates/named.conf.primary-zone.j2
dest: "{{ zone_config_file }}"
mode: "644"
- name: "Including zone configuration to global configuration"
ansible.builtin.blockinfile:
path: "{{ dns.path.etc }}/named.conf.local"
path: "{{ dns.paths.etc }}/named.conf.local"
state: present
marker: "// {mark} ANSIBLE MANAGED BLOCK FOR {{ domain_name }} ZONE"
block: |

View file

@ -1,5 +1,5 @@
acl "{{ domain_name }}-acl" {
{% if transfer_hosts %}
{% if transfer_hosts is defined and transfer_hosts|length %}
{% for ip in transfer_hosts %}
{{ ip }};
{% endfor %}
@ -18,5 +18,5 @@ zone "{{ domain_name }}" IN {
allow-update { none; };
allow-transfer { {{ domain_name }}-acl; };
notify yes;
key-directory "{{ dns.paths.keys }}";
key-directory "{{ dns.paths.keys_dir }}";
};

View file

@ -2,8 +2,11 @@ dns:
paths:
etc: /etc/bind/
primary_zones: /etc/bind/primary
keys: /etc/bind/primary/keys
keys_dir: /etc/bind/primary/keys
user: bind
group: bind
zones:
- zone:
domain_name: trans13nrv.eu.org
root:
user: root