|
|
|
- name: build default tld list
|
|
|
|
set_fact:
|
|
|
|
coredns_tld_list: "{{ [ ns_tld | d(int_tld) ] }}"
|
|
|
|
when: coredns_tld_list is not defined
|
|
|
|
|
|
|
|
|
|
|
|
- name: install coredns and dependencies
|
|
|
|
include_tasks: tasks/install_packages.yml
|
|
|
|
vars:
|
|
|
|
package:
|
|
|
|
- coredns
|
|
|
|
- alpine: coredns-openrc
|
|
|
|
|
|
|
|
|
|
|
|
- name: create user and group
|
|
|
|
include_tasks: tasks/create_user.yml
|
|
|
|
vars:
|
|
|
|
user:
|
|
|
|
name: "{{ coredns_user }}"
|
|
|
|
group: "{{ coredns_group }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: create config directory
|
|
|
|
file:
|
|
|
|
path: "{{ coredns_conf_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ coredns_user }}"
|
|
|
|
group: "{{ coredns_group }}"
|
|
|
|
notify: restart coredns
|
|
|
|
|
|
|
|
|
|
|
|
- name: template corefile
|
|
|
|
template:
|
|
|
|
src: corefile.j2
|
|
|
|
dest: "{{ coredns_conf_file }}"
|
|
|
|
force: yes
|
|
|
|
owner: "{{ coredns_user }}"
|
|
|
|
group: "{{ coredns_group }}"
|
|
|
|
mode: 0400
|
|
|
|
notify: restart coredns
|
|
|
|
|
|
|
|
|
|
|
|
- name: template empty tls file if missing
|
|
|
|
copy:
|
|
|
|
content: ''
|
|
|
|
dest: "{{ coredns_tls_file }}"
|
|
|
|
force: no
|
|
|
|
owner: "{{ coredns_user }}"
|
|
|
|
group: "{{ coredns_group }}"
|
|
|
|
mode: 0400
|
|
|
|
notify: restart coredns
|
|
|
|
|
|
|
|
|
|
|
|
- name: template all zones if missing
|
|
|
|
template:
|
|
|
|
src: zone.j2
|
|
|
|
dest: "{{ (coredns_conf_dir, zone ~ '.zone') | path_join }}"
|
|
|
|
force: no
|
|
|
|
mode: 0400
|
|
|
|
owner: "{{ coredns_user }}"
|
|
|
|
group: "{{ coredns_group }}"
|
|
|
|
notify: restart coredns
|
|
|
|
loop: "{{ coredns_tld_list }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: zone
|
|
|
|
|
|
|
|
|
|
|
|
- name: edit service config
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/conf.d/coredns
|
|
|
|
regexp: "^COREDNS_CONFIG="
|
|
|
|
line: "COREDNS_CONFIG={{ coredns_conf_file | quote }}"
|
|
|
|
notify: restart coredns
|
|
|
|
|
|
|
|
|
|
|
|
- name: template init script
|
|
|
|
template:
|
|
|
|
src: init.j2
|
|
|
|
dest: /etc/init.d/coredns
|
|
|
|
force: yes
|
|
|
|
mode: 0755
|
|
|
|
notify: restart coredns
|
|
|
|
|
|
|
|
|
|
|
|
- name: flush handlers
|
|
|
|
meta: flush_handlers
|
|
|
|
|
|
|
|
|
|
|
|
- name: add directories to backup plan
|
|
|
|
include_role:
|
|
|
|
name: backup
|
|
|
|
tasks_from: add.yml
|
|
|
|
vars:
|
|
|
|
backup_items:
|
|
|
|
- "{{ coredns_conf_dir }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: enable and start coredns
|
|
|
|
service:
|
|
|
|
name: coredns
|
|
|
|
enabled: yes
|
|
|
|
state: started
|