add nsd role
This commit is contained in:
parent
2da2a1affc
commit
2b4fdbc661
17
roles/nsd/defaults/main.yaml
Normal file
17
roles/nsd/defaults/main.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
nsd_package_name: nsd
|
||||||
|
nsd_package_state: present
|
||||||
|
|
||||||
|
nsd_service_name: nsd
|
||||||
|
nsd_service_state: started
|
||||||
|
nsd_service_enabled: yes
|
||||||
|
|
||||||
|
nsd_etc_path: /etc/nsd
|
||||||
|
nsd_zone_path: "{{ nsd_etc_path }}/zones"
|
||||||
|
|
||||||
|
nsd_server_config:
|
||||||
|
verbosity: 2
|
||||||
|
zonesdir: "{{ nsd_zone_path }}"
|
||||||
|
ip-address:
|
||||||
|
- "{{ ansible_default_ipv4.address }}"
|
||||||
|
- "{{ ansible_default_ipv6.address }}"
|
10
roles/nsd/handlers/main.yaml
Normal file
10
roles/nsd/handlers/main.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: reload nsd
|
||||||
|
service:
|
||||||
|
name: "{{ nsd_service_name }}"
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: restart nsd
|
||||||
|
service:
|
||||||
|
name: "{{ nsd_service_name }}"
|
||||||
|
state: restarted
|
36
roles/nsd/tasks/main.yaml
Normal file
36
roles/nsd/tasks/main.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
- name: install package
|
||||||
|
package:
|
||||||
|
name: "{{ nsd_package_name }}"
|
||||||
|
state: "{{ nsd_package_state }}"
|
||||||
|
|
||||||
|
- name: create zone directory
|
||||||
|
file:
|
||||||
|
path: "{{ nsd_zone_path }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: configure
|
||||||
|
template:
|
||||||
|
src: nsd.conf.j2
|
||||||
|
dest: "{{ nsd_etc_path }}/nsd.conf"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart nsd
|
||||||
|
|
||||||
|
- name: configure zones
|
||||||
|
copy:
|
||||||
|
src: "files/nsd/zones/{{ item.filename | default(item.name + '.zone') }}"
|
||||||
|
dest: "{{ nsd_zone_path }}/{{ item.name }}.zone"
|
||||||
|
owner: root
|
||||||
|
group: nsd
|
||||||
|
mode: 0640
|
||||||
|
validate: "nsd-checkzone {{ item.name }} %s"
|
||||||
|
loop: "{{ nsd_zones | default([]) }}"
|
||||||
|
notify: reload nsd
|
||||||
|
|
||||||
|
- name: manage service
|
||||||
|
service:
|
||||||
|
name: "{{ nsd_service_name }}"
|
||||||
|
state: "{{ nsd_service_state }}"
|
||||||
|
enabled: "{{ nsd_service_enabled }}"
|
34
roles/nsd/templates/nsd.conf.j2
Normal file
34
roles/nsd/templates/nsd.conf.j2
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% if nsd_server_config is defined and
|
||||||
|
nsd_server_config is mapping %}
|
||||||
|
server:
|
||||||
|
{% for k, v in nsd_server_config.items() %}
|
||||||
|
{% if v is string or v is number %}
|
||||||
|
{{ k }}: {{ v }}
|
||||||
|
{% elif v is sequence %}
|
||||||
|
{% for vv in v %}
|
||||||
|
{{ k }}: {{ vv }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if nsd_zones is defined and
|
||||||
|
nsd_zones is sequence %}
|
||||||
|
{% for zone in nsd_zones %}
|
||||||
|
{% if zone is defined and
|
||||||
|
zone is mapping %}
|
||||||
|
zone:
|
||||||
|
{% for k, v in zone.items() %}
|
||||||
|
{% if v is string %}
|
||||||
|
{{ k }}: {{ v }}
|
||||||
|
{% elif v is sequence %}
|
||||||
|
{% for vv in v %}
|
||||||
|
{{ k }}: {{ vv }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
Loading…
Reference in New Issue
Block a user