2022-02-21 20:41:31 +00:00
|
|
|
---
|
|
|
|
|
2022-12-28 21:05:01 +00:00
|
|
|
- name: Include OS-specific variables
|
2022-02-21 20:41:31 +00:00
|
|
|
include_vars: "{{ ansible_os_family }}.yml"
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Install bind and dependencies
|
2022-02-21 20:41:31 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items: "{{ bind_package_names }}"
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Create logging directory
|
2022-02-21 20:41:31 +00:00
|
|
|
file:
|
|
|
|
path: "{{ bind_log_directory }}"
|
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
|
|
|
mode: 0755
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Create config directory
|
|
|
|
file:
|
|
|
|
path: "{{ bind_config_directory }}"
|
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
|
|
|
mode: 0755
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
|
|
|
|
- name: Remove existing journal files
|
2022-02-21 20:41:31 +00:00
|
|
|
block:
|
|
|
|
- name: find existing journal files
|
|
|
|
find:
|
|
|
|
path: "{{ bind_config_directory }}"
|
|
|
|
recurse: yes
|
|
|
|
patterns: "*.jnl"
|
|
|
|
register: files_to_delete
|
|
|
|
- name: delete existing journal files
|
|
|
|
file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ files_to_delete.files }}"
|
|
|
|
|
|
|
|
|
|
|
|
# - name: copy zone files
|
|
|
|
# include_tasks: copy_zone_files.yml
|
|
|
|
# with_items:
|
|
|
|
# - "{{ bind9_views }}"
|
|
|
|
# loop_control:
|
|
|
|
# loop_var: view
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Create DNS-Zone files
|
2022-02-21 20:41:31 +00:00
|
|
|
include_tasks: template_zone_files.yml
|
|
|
|
with_items:
|
|
|
|
- "{{ bind9_views }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: view
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Create main configuration file
|
|
|
|
template:
|
|
|
|
src: "etc/named.conf.j2"
|
|
|
|
dest: "{{ bind_main_config }}"
|
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
|
|
|
mode: 0644
|
|
|
|
notify: restart named
|
|
|
|
|
|
|
|
- name: Create excluded configuration files
|
2022-02-21 20:41:31 +00:00
|
|
|
template:
|
|
|
|
src: "{{ item }}.j2"
|
2022-04-04 14:00:11 +00:00
|
|
|
dest: "{{ item | replace('etc/named', bind_config_directory) }}"
|
2022-02-21 20:41:31 +00:00
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
2022-04-04 14:00:11 +00:00
|
|
|
- etc/named.conf
|
|
|
|
- etc/named/named.conf.acl
|
|
|
|
- etc/named/named.conf.logging
|
|
|
|
- etc/named/named.conf.options
|
|
|
|
- etc/named/named.conf.tsigkeys
|
|
|
|
- etc/named/named.conf.views
|
2022-02-21 20:41:31 +00:00
|
|
|
notify: restart named
|
|
|
|
|
2022-04-04 14:00:11 +00:00
|
|
|
- name: Start and enabled named
|
2022-02-21 20:41:31 +00:00
|
|
|
systemd:
|
|
|
|
name: named
|
|
|
|
state: started
|
|
|
|
enabled: yes
|