Deploy coredns as a proxy to Docker's internal DNS
This commit is contained in:
parent
7381c1f10a
commit
7ad5d6e51e
5 changed files with 59 additions and 0 deletions
|
@ -105,6 +105,7 @@
|
||||||
- commento
|
- commento
|
||||||
- website
|
- website
|
||||||
- remark42
|
- remark42
|
||||||
|
- coredns
|
||||||
|
|
||||||
- hosts: jellyfin
|
- hosts: jellyfin
|
||||||
roles:
|
roles:
|
||||||
|
|
21
ansible/roles/coredns/files/Corefile
Normal file
21
ansible/roles/coredns/files/Corefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
. {
|
||||||
|
errors
|
||||||
|
cancel
|
||||||
|
|
||||||
|
# Only allow requests to `.docker` records
|
||||||
|
view docker {
|
||||||
|
expr name() matches '^[a-zA-Z0-9-_]+\\.docker\\.$'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Strip the `.docker` suffix
|
||||||
|
rewrite name suffix .docker . answer auto
|
||||||
|
|
||||||
|
# Forward requests to Docker's DNS server
|
||||||
|
forward . 127.0.0.11
|
||||||
|
}
|
||||||
|
|
||||||
|
. {
|
||||||
|
acl {
|
||||||
|
block
|
||||||
|
}
|
||||||
|
}
|
16
ansible/roles/coredns/files/docker-compose.yml
Normal file
16
ansible/roles/coredns/files/docker-compose.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version: "2.3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
coredns:
|
||||||
|
image: coredns/coredns:latest
|
||||||
|
volumes:
|
||||||
|
- ./Corefile:/home/nonroot/Corefile:ro
|
||||||
|
ports:
|
||||||
|
- "{{ private_ip }}:5353:53/udp"
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
- traefik
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
external: true
|
4
ansible/roles/coredns/handlers/main.yml
Normal file
4
ansible/roles/coredns/handlers/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- name: restart coredns
|
||||||
|
shell:
|
||||||
|
chdir: /opt/coredns
|
||||||
|
cmd: "{{ docker_update_command }}"
|
17
ansible/roles/coredns/tasks/main.yml
Normal file
17
ansible/roles/coredns/tasks/main.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
- name: Create install directory
|
||||||
|
file:
|
||||||
|
path: /opt/coredns
|
||||||
|
state: directory
|
||||||
|
owner: "{{ docker_user.name }}"
|
||||||
|
mode: "{{ docker_compose_directory_mask }}"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Install compose file
|
||||||
|
template:
|
||||||
|
src: files/docker-compose.yml
|
||||||
|
dest: /opt/coredns/docker-compose.yml
|
||||||
|
mode: "{{ docker_compose_file_mask }}"
|
||||||
|
owner: "{{ docker_user.name }}"
|
||||||
|
validate: docker-compose -f %s config
|
||||||
|
notify: restart coredns
|
||||||
|
become: true
|
Loading…
Reference in a new issue