init
This commit is contained in:
commit
cb3ed889db
9
defaults/main.yml
Normal file
9
defaults/main.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
path: /srv/{{ role_name }}
|
||||||
|
|
||||||
|
dns_override: {}
|
||||||
|
dns_defaults:
|
||||||
|
api_key: ""
|
||||||
|
domain: ""
|
||||||
|
local_domains: []
|
||||||
|
domain_host: ""
|
||||||
|
domain_host_v6: ""
|
||||||
9
handlers/main.yml
Normal file
9
handlers/main.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
- name: restart container
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ path }}"
|
||||||
|
project_name: "{{ role_name }}"
|
||||||
|
recreate: "always"
|
||||||
|
services: ["pihole"]
|
||||||
|
state: "restarted"
|
||||||
|
|
||||||
|
when: _dns_already_restarted is deffined and not _dns_already_restarted
|
||||||
17
meta/main.yml
Normal file
17
meta/main.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: "Niklas Freese <niklas@urmel.de>"
|
||||||
|
description: dns
|
||||||
|
company: "Urmel Services"
|
||||||
|
license: AGPL-3.0-or-later
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
33
tasks/main.yml
Normal file
33
tasks/main.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
- name: "set local variables from overrides and defaults"
|
||||||
|
set_fact:
|
||||||
|
dns: "{{ (dns_defaults | combine(dns_override, recursive=True)) if dns_override else dns_defaults }}"
|
||||||
|
|
||||||
|
- name: ensure that path exists
|
||||||
|
file:
|
||||||
|
path: "{{ path }}/config/dns"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: template docker-compose
|
||||||
|
template:
|
||||||
|
src: compose.yml.j2
|
||||||
|
dest: "{{ path }}/compose.yml"
|
||||||
|
|
||||||
|
- name: populate dmasq
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "dmasq.conf/{{ item.path }}"
|
||||||
|
dest: "{{ path }}/config/etc-dnsmasq.d/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||||
|
with_filetree: "{{ role_path }}/templates/dmasq.conf"
|
||||||
|
when:
|
||||||
|
- item.state == "file"
|
||||||
|
notify: restart container
|
||||||
|
|
||||||
|
- name: ensure container is running
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ path }}"
|
||||||
|
project_name: "{{ role_name }}"
|
||||||
|
state: "present"
|
||||||
|
pull: "always"
|
||||||
|
wait: true
|
||||||
|
services: ["pihole"]
|
||||||
|
register: _compose_result
|
||||||
34
templates/compose.yml.j2
Normal file
34
templates/compose.yml.j2
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
pihole:
|
||||||
|
image: pihole/pihole:latest
|
||||||
|
ports:
|
||||||
|
- "53:53/tcp"
|
||||||
|
- "53:53/udp"
|
||||||
|
- "67:67/udp"
|
||||||
|
environment:
|
||||||
|
TZ: 'Europe/Berlin'
|
||||||
|
FTLCONF_webserver_api_password: '{{ dns.api_key }}'
|
||||||
|
FTLCONF_dns_listeningMode: 'ALL' # recomendet for docker bridge
|
||||||
|
volumes:
|
||||||
|
- './data/pihole:/etc/pihole'
|
||||||
|
- './config/etc-dnsmasq.d:/etc/dnsmasq.d'
|
||||||
|
networks:
|
||||||
|
- exposed
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN # For DHCP
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
traefik.enable: true
|
||||||
|
|
||||||
|
traefik.http.routers.pihole.entrypoints: https
|
||||||
|
traefik.http.routers.pihole.rule: Host(`{{ dns.domain }}`)
|
||||||
|
traefik.http.services.pihole.loadbalancer.server.port: 80
|
||||||
|
traefik.http.routers.pihole.tls: "true"
|
||||||
|
traefik.http.routers.pihole.tls.certresolver: hetzner
|
||||||
|
traefik.http.routers.pihole.middlewares: local-only@file
|
||||||
|
|
||||||
|
networks:
|
||||||
|
exposed:
|
||||||
|
name: traefik_exposed
|
||||||
|
external: true
|
||||||
1
templates/dmasq.conf/02-pihole-dhcp.conf.j2
Normal file
1
templates/dmasq.conf/02-pihole-dhcp.conf.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
dhcp-option=6,{{ ansible_facts.default_ipv4.address }}
|
||||||
5
templates/dmasq.conf/99-local-wildcard.conf.j2
Normal file
5
templates/dmasq.conf/99-local-wildcard.conf.j2
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{% for local_domain in dns.local_domains %}
|
||||||
|
address=/.{{ local_domain }}/{{ dns.domain_host | default(ansible_facts.default_ipv4.address, true) }}
|
||||||
|
address=/.{{ local_domain }}/{{ dns.domain_host_v6 | default(ansible_facts.default_ipv6.address, true) }}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
Loading…
x
Reference in New Issue
Block a user