-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Consul DNS forwarding with dnsmasq
- Loading branch information
Showing
7 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
- name: Install dnsmasq | ||
apt: | ||
name: | ||
- dnsmasq | ||
state: present | ||
|
||
- name: Remove resolvconf | ||
apt: | ||
name: | ||
- resolvconf | ||
- openresolv | ||
state: absent | ||
|
||
- name: Allow ufw port 53 | ||
ufw: | ||
rule: "allow" | ||
port: 53 | ||
|
||
- name: Disable systemd-resolved | ||
systemd: | ||
name: systemd-resolved | ||
state: stopped | ||
enabled: false | ||
|
||
- name: Write new /etc/resolv.conf | ||
copy: | ||
content: "nameserver 127.0.0.1" | ||
dest: "/etc/resolv.conf" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
|
||
- name: Copy dnsmasq config | ||
template: | ||
src: "dnsmasq.conf.j2" | ||
dest: "/etc/dnsmasq.conf" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
|
||
- name: Copy Consul dnsmasq forwarding config | ||
copy: | ||
content: | | ||
server=/consul/127.0.0.1#8600 | ||
rev-server=10.0.0.0/8,127.0.0.1#8600 | ||
dest: "/etc/dnsmasq.d/10-consul" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
|
||
- name: Start dnsmasq | ||
systemd: | ||
name: dnsmasq | ||
state: started | ||
enabled: true | ||
|
||
- name: Wait for port 53 | ||
wait_for: | ||
port: 53 | ||
host: "{{ ansible_default_ipv4.address }}" | ||
state: started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
listen-address={{ ansible_default_ipv4.address }},127.0.0.1 | ||
{% for addr in consul_upstream_dns_address %} | ||
server={{ addr }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
} | ||
|
||
consul:{{ coredns_dns_port }} { | ||
forward . 10.10.10.110:8600 | ||
forward . 10.10.10.110 | ||
log | ||
errors | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters