2019-10-09 18:15:55 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: 'packages are installed'
|
2017-02-22 17:06:09 +01:00
|
|
|
apt:
|
2017-07-22 18:40:00 +02:00
|
|
|
name: '{{ item }}'
|
2019-10-09 18:15:55 +02:00
|
|
|
state: 'present'
|
2017-07-22 18:40:00 +02:00
|
|
|
with_items:
|
2019-10-09 18:15:55 +02:00
|
|
|
- 'bind9'
|
|
|
|
- 'dnstop'
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'Set bind configuration for recursive server'
|
2017-04-13 17:12:16 +02:00
|
|
|
template:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'named.conf.options_recursive.j2'
|
|
|
|
dest: '/etc/bind/named.conf.options'
|
|
|
|
owner: 'bind'
|
|
|
|
group: 'bind'
|
|
|
|
mode: '0644'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
2019-10-09 18:15:55 +02:00
|
|
|
notify: 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_recursive_server
|
2017-04-13 17:12:16 +02:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'enable zones.rfc1918 for recursive server'
|
2017-07-22 18:40:00 +02:00
|
|
|
lineinfile:
|
2019-10-09 18:15:55 +02:00
|
|
|
dest: '/etc/bind/named.conf.local'
|
2017-07-22 18:40:00 +02:00
|
|
|
line: 'include "/etc/bind/zones.rfc1918";'
|
2019-10-09 18:15:55 +02:00
|
|
|
regexp: 'zones.rfc1918'
|
|
|
|
notify: 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_recursive_server
|
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'Set bind configuration for authoritative server'
|
2017-07-22 18:40:00 +02:00
|
|
|
template:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'named.conf.options_authoritative.j2'
|
|
|
|
dest: '/etc/bind/named.conf.options'
|
|
|
|
owner: 'bind'
|
|
|
|
group: 'bind'
|
|
|
|
mode: '0644'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
2019-10-09 18:15:55 +02:00
|
|
|
notify: 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_authoritative_server
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'Create systemd service'
|
2017-04-06 14:21:29 +02:00
|
|
|
template:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'bind9.service.j2'
|
2017-04-06 14:21:29 +02:00
|
|
|
dest: "{{ bind_systemd_service_path }}"
|
2019-10-09 18:15:55 +02:00
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
|
|
|
mode: '0644'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
2017-07-22 18:40:00 +02:00
|
|
|
notify:
|
2019-10-09 18:15:55 +02:00
|
|
|
- 'reload systemd'
|
|
|
|
- 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: ansible_distribution_release == "jessie"
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'touch /var/log/bind.log if non chroot'
|
2017-02-22 17:06:09 +01:00
|
|
|
file:
|
2019-10-09 18:15:55 +02:00
|
|
|
path: '/var/log/bind.log'
|
|
|
|
owner: 'bind'
|
|
|
|
group: 'adm'
|
|
|
|
mode: '0640'
|
|
|
|
state: 'touch'
|
2019-10-09 18:07:14 +02:00
|
|
|
when: not bind_chroot_set
|
2017-04-06 14:33:46 +02:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'touch /var/log/bind_queries.log if non chroot'
|
2017-02-22 17:06:09 +01:00
|
|
|
file:
|
2019-10-09 18:15:55 +02:00
|
|
|
path: '/var/log/bind_queries.log'
|
|
|
|
owner: 'bind'
|
|
|
|
group: 'adm'
|
|
|
|
mode: '0640'
|
|
|
|
state: 'touch'
|
2019-10-09 18:07:14 +02:00
|
|
|
when: not bind_chroot_set
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'send chroot-bind.sh in /root'
|
2017-07-22 18:40:00 +02:00
|
|
|
copy:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'chroot-bind.sh'
|
|
|
|
dest: '/root/chroot-bind.sh'
|
|
|
|
mode: '0700'
|
|
|
|
owner: 'root'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
|
|
|
backup: true
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_chroot_set
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'exec chroot-bind.sh'
|
|
|
|
command: '/root/chroot-bind.sh'
|
2017-07-22 18:40:00 +02:00
|
|
|
register: chrootbind_run
|
2019-10-09 18:07:14 +02:00
|
|
|
changed_when: false
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_chroot_set
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2017-07-22 18:40:00 +02:00
|
|
|
- debug:
|
|
|
|
var: chrootbind_run.stdout_lines
|
|
|
|
when: bind_chroot_set and chrootbind_run.stdout != ""
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'Modify OPTIONS in /etc/default/bind9 for chroot'
|
2017-07-22 18:40:00 +02:00
|
|
|
replace:
|
2019-10-09 18:15:55 +02:00
|
|
|
dest: '/etc/default/bind9'
|
2017-07-22 18:40:00 +02:00
|
|
|
regexp: '^OPTIONS=.*'
|
|
|
|
replace: 'OPTIONS="-u bind -t {{ bind_chroot_path }}"'
|
2019-10-09 18:15:55 +02:00
|
|
|
notify: 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_chroot_set
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'logrotate for non chroot bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
template:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'logrotate_bind'
|
|
|
|
dest: '/etc/logrotate.d/bind9'
|
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
|
|
|
mode: '0644'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
2019-10-09 18:15:55 +02:00
|
|
|
notify: 'restart bind'
|
2019-10-09 18:07:14 +02:00
|
|
|
when: not bind_chroot_set
|
2017-02-22 17:06:09 +01:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- name: 'logrotate for chroot bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
template:
|
2019-10-09 18:15:55 +02:00
|
|
|
src: 'logrotate_bind_chroot.j2'
|
|
|
|
dest: '/etc/logrotate.d/bind9'
|
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
|
|
|
mode: '0644'
|
2019-10-09 18:07:14 +02:00
|
|
|
force: true
|
2019-10-09 18:15:55 +02:00
|
|
|
notify: 'restart bind'
|
2017-07-22 18:40:00 +02:00
|
|
|
when: bind_chroot_set
|
2019-10-09 17:47:07 +02:00
|
|
|
|
2019-10-09 18:15:55 +02:00
|
|
|
- include: 'munin.yml'
|