role_dnsmasq/tasks/configuration.yml

62 lines
1.5 KiB
YAML

---
# tasks file for dnsmasq
- name: Create path to override systemd-resolved
ansible.builtin.file:
path: "{{ dnsmasq_resolved_directory }}"
state: directory
owner: root
group: root
mode: u=rwX,g=rX,o=rX
become: true
notify: Restart systemd-resolved.service
- name: Disable stub resolver of systemd-resolved
ansible.builtin.template:
src: stub-listener.conf.j2
dest: "{{ dnsmasq_resolved_directory }}/stub-listener.conf"
owner: root
group: root
mode: u=rw,g=r,o=r
become: true
notify: Restart systemd-resolved.service
- name: Flush handlers
meta: flush_handlers
- name: Create records directory
ansible.builtin.file:
path: "{{ dnsmasq_records_directory }}"
state: directory
owner: dnsmasq
group: root
mode: u=rwX,g=rX,o=rX
become: true
- name: Remove old configuration
ansible.builtin.file:
path: "{{ dnsmasq_conf_directory }}/cache.conf"
state: absent
become: true
- name: Deploy configuration
ansible.builtin.template:
src: dnsmasq.conf.j2
dest: "{{ dnsmasq_conf_directory }}/dns.conf"
owner: root
group: root
mode: u=rw,g=r,o=r
become: true
notify: Restart dnsmasq.service
- name: Deploy specific records
ansible.builtin.template:
src: "{{ role_path }}/templates/records_specific.conf.j2"
dest: "{{ dnsmasq_records_directory }}/specific.conf"
owner: dnsmasq
group: root
mode: u=rw,g=r,o=r
when: dnsmasq_specifics | length > 0
become: true
notify: Restart dnsmasq.service