ansible-role-bind/tasks/zones.yml

47 lines
1.3 KiB
YAML
Raw Normal View History

- set_fact:
bind_zones_play: '{{ bind_zones_play|default([]) + [ item ] }}'
2018-12-05 09:16:43 +00:00
loop: '{{ bind_zones|dict2items }}'
when: (item.value.state is not defined or item.value.state != 'absent') and (bind_zones_subset is not defined or item.key in bind_zones_subset)
2018-03-31 15:50:50 +00:00
- name: create zone folder
file:
path: '/etc/bind/zones/{{ item.key }}'
owner: bind
group: bind
mode: 0755
state: directory
2018-12-05 09:16:43 +00:00
loop: '{{ bind_zones_play }}'
2018-03-31 15:50:50 +00:00
2018-03-28 15:45:57 +00:00
- name: copy zone files
template:
src: db.j2
2018-03-31 15:50:50 +00:00
dest: '/etc/bind/zones/{{ item.key }}/db'
2018-03-28 15:45:57 +00:00
owner: root
group: root
mode: 0644
2018-12-05 09:16:43 +00:00
loop: '{{ bind_zones_play }}'
2018-03-28 15:45:57 +00:00
register: zone
notify: reload bind
- name: dnssec sign
2018-03-31 15:50:50 +00:00
shell: 'dnssec-signzone -3 $(head -n 1000 /dev/urandom | sha1sum | cut -b 1-16) -A -N INCREMENT -o {{ item.item.key }} -t /etc/bind/zones/{{ item.item.key }}/db'
2018-03-28 15:45:57 +00:00
args:
chdir: /etc/bind/keys
2018-12-05 09:16:43 +00:00
loop: '{{ zone.results }}'
2018-10-07 10:57:36 +00:00
when: item.changed and item.item.key in bind_dnssec
2018-03-28 15:45:57 +00:00
notify: reload bind
2018-03-31 15:50:50 +00:00
- name: get zones files
find:
path: /etc/bind/zones
file_type: directory
recurse: no
register: zone_folders
- name: delete old zone file
file:
path: '{{ item.path }}'
state: absent
2018-12-05 09:16:43 +00:00
loop: '{{ zone_folders.files }}'
2018-03-31 15:50:50 +00:00
when: item.path|basename not in bind_zones or ('state' in bind_zones[item.path|basename] and bind_zones[item.path|basename].state == 'absent')