52 lines
1.2 KiB
YAML
52 lines
1.2 KiB
YAML
---
|
|
- name: Install Dnsmasq package
|
|
package:
|
|
name: "{{ dnsmasq_package }}"
|
|
state: present
|
|
|
|
- name: Create Dnsmasq configuration directory
|
|
file:
|
|
path: /etc/dnsmasq.d
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: 0700
|
|
|
|
- name: Create Dnsmasq configuration
|
|
template:
|
|
src: dnsmasq-10-consul.j2
|
|
dest: /etc/dnsmasq.d/10-consul.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify: restart dnsmasq
|
|
|
|
- name: Disable systemd-resolved
|
|
when: ansible_service_mgr == "systemd"
|
|
block:
|
|
- name: Disable systemd-resolved service
|
|
service:
|
|
name: systemd-resolved
|
|
enabled: false
|
|
state: stopped
|
|
|
|
- name: Check if resolv.conf is pointing to systemd-resolved
|
|
stat:
|
|
path: /etc/resolv.conf
|
|
register: resolv_dot_conf
|
|
|
|
- name: Remove resolv.conf association with systemd-resolved
|
|
file:
|
|
src: /run/resolvconf/resolv.conf
|
|
path: /etc/resolv.conf
|
|
state: link
|
|
when:
|
|
- resolv_dot_conf.stat.islnk
|
|
- 'resolv_dot_conf.stat.link_source == "/run/systemd/resolve/stub-resolv.conf"'
|
|
|
|
- name: ensure DNSmasq is started
|
|
service:
|
|
name: dnsmasq
|
|
state: started
|
|
enabled: true
|