diff --git a/tasks/main.yml b/tasks/main.yml index 85a685b..5cb62bc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -109,20 +109,17 @@ - name: Systemd-resolved forwarding when: _consul.use_dns_forwarding | default(false) block: - - name: Create /etc/systemd/resolved.conf.d/ - ansible.builtin.file: - path: /etc/systemd/resolved.conf.d/ - state: directory - owner: root - group: root - - - name: Create systemd-resolved config to forward consul domain to agent - ansible.builtin.template: - src: "{{ item }}.j2" - dest: /{{ item }} - mode: "0644" + - name: Configure systemd-resolved + community.general.ini_file: + path: /etc/systemd/resolved.conf.d/consul.conf + section: "Resolve" + option: "{{ item.key }}" + value: "{{ item.value }}" + state: present + mode: '0644' loop: - - etc/systemd/resolved.conf.d/consul.conf + - { key: DNS, value: "127.0.0.1:{{ _consul.dns_port | default(8600) }}" } + - { key: Domains, value: "~{{ _consul.domain }}" } register: systemd_resolved_consul - name: Restart systemd-resolved diff --git a/templates/etc/systemd/resolved.conf.d/consul.conf.j2 b/templates/etc/systemd/resolved.conf.d/consul.conf.j2 deleted file mode 100644 index 3af9498..0000000 --- a/templates/etc/systemd/resolved.conf.d/consul.conf.j2 +++ /dev/null @@ -1,4 +0,0 @@ -[Resolve] -DNS=127.0.0.1:{{ _consul.dns_port|default(8600) }} -DNSSEC=false -Domains=~{{ _consul.domain }}