ansible-consul/tasks/dnsmasq.yml

52 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2022-04-03 18:39:52 +00:00
---
- name: Install Dnsmasq package
2023-10-31 19:08:20 +00:00
ansible.builtin.package:
2022-04-03 18:39:52 +00:00
name: "{{ dnsmasq_package }}"
state: present
- name: Create Dnsmasq configuration directory
2023-10-31 19:08:20 +00:00
ansible.builtin.file:
2022-04-03 18:39:52 +00:00
path: /etc/dnsmasq.d
state: directory
owner: root
group: root
2023-10-31 19:08:20 +00:00
mode: "0700"
2022-04-03 18:39:52 +00:00
- name: Create Dnsmasq configuration
2023-10-31 19:08:20 +00:00
ansible.builtin.template:
2022-04-03 18:39:52 +00:00
src: dnsmasq-10-consul.j2
dest: /etc/dnsmasq.d/10-consul.conf
owner: root
group: root
2023-10-31 19:08:20 +00:00
mode: "0644"
2022-04-03 18:39:52 +00:00
notify: restart dnsmasq
- name: Disable systemd-resolved
when: ansible_service_mgr == "systemd"
block:
- name: Disable systemd-resolved service
2023-10-31 19:08:20 +00:00
ansible.builtin.service:
2022-04-03 18:39:52 +00:00
name: systemd-resolved
enabled: false
state: stopped
- name: Check if resolv.conf is pointing to systemd-resolved
2023-10-31 19:08:20 +00:00
ansible.builtin.stat:
2022-04-03 18:39:52 +00:00
path: /etc/resolv.conf
register: resolv_dot_conf
- name: Remove resolv.conf association with systemd-resolved
2023-10-31 19:08:20 +00:00
ansible.builtin.file:
2022-04-03 18:39:52 +00:00
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"'
2023-10-31 19:08:20 +00:00
- name: Ensure DNSmasq is started
ansible.builtin.service:
2022-04-03 18:39:52 +00:00
name: dnsmasq
state: started
enabled: true