-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathmain.yml
118 lines (106 loc) · 2.88 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
# Initialise distribution-specific variables
- name: Source specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution_file_variety }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution_file_variety }}.yml"
tags: bind
- name: Check `primaries` or `forwarders` was set for each zone
assert:
that:
- item.primaries is defined or item.forwarders is defined
quiet: yes
loop: "{{ bind_zones }}"
loop_control:
label: "{{ item.name }}"
tags: bind
# Fix molecule and ci failures
- name: Update package cache for Debian based distros
apt:
update_cache: yes
become: yes
changed_when: false
when: ansible_os_family == 'Debian'
tags: bind
- name: Assert that all XFR keys exist in the key list
assert:
that: bind_dns_keys | selectattr("name","equalto",bind_key_mapping[item]) | list | count > 0
loop: "{{ bind_key_mapping.keys() | list }}"
when: bind_key_mapping | list | count > 0
- name: Install BIND
package:
pkg: "{{ item }}"
state: present
become: yes
with_items:
- "{{ bind_packages }}"
tags: bind
- name: Ensure runtime directories referenced in config exist
file:
path: "{{ item }}"
state: directory
owner: "{{ bind_owner }}"
group: "{{ bind_group }}"
mode: 0770
become: yes
with_items:
- "{{ bind_dir }}/dynamic"
- "{{ bind_dir }}/data"
- "{{ bind_zone_dir }}"
tags: bind
- name: Ensure Directory for Cached Secondary Zones exists
file:
path: "{{ bind_secondary_dir }}"
state: directory
owner: "{{ bind_owner }}"
group: "{{ bind_group }}"
mode: 0770
setype: named_cache_t
become: yes
tags: bind
- name: Create serial, based on UTC UNIX time
command: date -u +%s
register: timestamp
changed_when: false
run_once: true
check_mode: false
tags: bind
# file to set keys for XFR authentication
- name: Create extra config for authenticated XFR request
template:
src: auth_transfer.j2
dest: "{{ bind_conf_dir }}/{{ auth_file }}"
mode: 0640
owner: root
group: "{{ bind_group }}"
become: yes
when: bind_dns_keys is defined and bind_dns_keys|length > 0
notify: reload bind
tags: bind
- name: Configure zones
include_tasks: zones.yml
tags: bind
- name: Main BIND config file
template:
src: etc_named.conf.j2
dest: "{{ bind_config }}"
owner: "{{ bind_owner }}"
group: "{{ bind_group }}"
mode: 0640
setype: named_conf_t
validate: 'named-checkconf %s'
become: yes
notify: reload bind
tags: bind
- name: Start BIND service
service:
name: "{{ bind_service }}"
state: started
enabled: true
become: yes
tags: bind