First commit - Added DNS playbooks
This commit is contained in:
commit
2a01f9e57d
8 changed files with 143 additions and 0 deletions
44
playbooks/01-primary-ns.yaml
Normal file
44
playbooks/01-primary-ns.yaml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
- hosts: dns-hosts
|
||||
name: Configuration of ns zones
|
||||
|
||||
tasks:
|
||||
- name: Use variables
|
||||
include_vars: vars.yml
|
||||
|
||||
|
||||
- name: Ensure bind is installed
|
||||
package:
|
||||
name: bind9
|
||||
state: latest
|
||||
|
||||
- name: Ensure dnssec-tools is installed
|
||||
package:
|
||||
name: dnsutils
|
||||
state: latest
|
||||
|
||||
- name: Ensure required master zone directory is present
|
||||
file:
|
||||
path: "{{ dns.paths.primary_zones }}"
|
||||
state: directory
|
||||
owner: "{{ root.user }}"
|
||||
group: "{{ dns.group }}"
|
||||
|
||||
- name: Ensure required keys zone directory is present
|
||||
file:
|
||||
path: "{{ dns.paths.keys }}"
|
||||
state: directory
|
||||
owner: "{{ dns.user }}"
|
||||
group: "{{ dns.group }}"
|
||||
|
||||
- name: Prymary Zones
|
||||
vars:
|
||||
zones:
|
||||
- zome:
|
||||
domain_name: trans13nrv.eu.org
|
||||
include_tasks: tasks/ns/primary-zone.yml
|
||||
loop: "{{ zones }}"
|
||||
|
||||
- name: Reload bind9 service
|
||||
service:
|
||||
name: bind9
|
||||
state: reloaded
|
||||
27
playbooks/tasks/ns/primary-zone.yml
Normal file
27
playbooks/tasks/ns/primary-zone.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: "Setup variable for zone {{ zone.domain_name }}"
|
||||
register:
|
||||
domain_name: "{{ zone.domain_name }}"
|
||||
transfer_hosts: "{{ zone.transfer_hosts }}"
|
||||
zone_config_file: "{{ dns.paths.etc }}/named.conf.{{ domain_name }}"
|
||||
zone_db_file: "{{ dns.paths.dns.paths.primary_zones }}/db.{{ zone.domain_zone }}"
|
||||
|
||||
- name: Updating primary zone db file
|
||||
file:
|
||||
src: "file/ns/zone/db.{{ domain_name }}"
|
||||
dest: "{{ zone_db_file }}"
|
||||
|
||||
- name: "Creating zone {{ domain_name }}"
|
||||
template:
|
||||
src: templates/ns/zone/named.conf.primary-zone.j2
|
||||
dest: "{{ zone_config_file }}"
|
||||
|
||||
- name: "Including zone configuration to global configuration"
|
||||
blockinfile:
|
||||
path: "{{ dns.path.etc }}/named.conf.local"
|
||||
state: present
|
||||
marker: "// {mark} ANSIBLE MANAGED BLOCK FOR {{ domain_name }} ZONE" # not required. The marker line template. C({mark}) will be replaced with the values C(in marker_begin) (default="BEGIN") and C(marker_end) (default="END"). Using a custom marker without the C({mark}) variable may result in the block being repeatedly inserted on subsequent playbook runs.
|
||||
block: |
|
||||
"include \"{{ zone_config_file }}\"";
|
||||
marker_begin: BEGIN
|
||||
marker_end: END
|
||||
9
playbooks/vars.yml
Normal file
9
playbooks/vars.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
dns:
|
||||
paths:
|
||||
etc: /etc/bind/
|
||||
primary_zones: /etc/bind/primary
|
||||
keys: /etc/bind/primary/keys
|
||||
user: bind
|
||||
group: bind
|
||||
root:
|
||||
user: root
|
||||
Loading…
Add table
Add a link
Reference in a new issue