Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: ADDITION: Pi-hole #321

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Ansible config and a bunch of Docker containers.
## What Ansible-NAS Can Set Up

* An awesome dashboard to your home server (Heimdall)
* Network-wide ad blocking, a black hole for Internet advertisements via Pi-hole.
* Any number of Samba shares or NFS exports for you to store your stuff
* A BitTorrent client
* A Usenet downloader
Expand Down Expand Up @@ -65,6 +66,7 @@ Ansible config and a bunch of Docker containers.
* [NZBget](https://nzbget.net/) - The most efficient usenet downloader
* [Ombi](https://ombi.io/) - web application that automatically gives your users the ability to request content
* [openHAB](https://www.openhab.org/) - A vendor and technology agnostic open source automation software for your home
* [Pi-hole](https://pi-hole.net/) - Network-wide ad blocking
* [Plex](https://www.plex.tv/) - Plex Media Server
* [Portainer](https://portainer.io/) - for managing Docker and running custom images
* [pyLoad](https://pyload.net/) - A download manager with a friendly web-interface
Expand Down
14 changes: 14 additions & 0 deletions docs/applications/pihole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Pi-hole

Homepage: [https://pi-hole.net/](https://pi-hole.net/)
Docker Container: [https://hub.docker.com/r/pihole/pihole](https://hub.docker.com/r/pihole/pihole)

Network-wide ad blocking, a black hole for Internet advertisements.

## Usage

Using Traefik: Set `pihole_with_traefik_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
Not using Traefik: Set `pihole_without_traefik_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.

The Pi-hole web interface can be found at http://ansible_nas_host_or_ip/admin.
7 changes: 7 additions & 0 deletions docs/configuration/application_ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ By default, applications can be found on the ports listed below.
| Ombi | 3579 | |
| openHAB | 7777 | HTTP |
| openHAB | 7778 | HTTPS |
| Organizr | 10081 | HTTP |
| Organizr | 10444 | HTTPS |
| Pi-hole | 53 | TCP & UDP |
| Pi-hole | 80 | w/o Traefik |
| Pi-hole | 443 | w/o Traefik |
| Pi-hole | 8182 | w/ Traefik |
| Pi-hole | 8183 | w/ Traefik |
| Plex | 32400 | |
| Portainer | 9000 | |
| pyload | 8000 | |
Expand Down
12 changes: 12 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ mosquitto_enabled: false
homebridge_enabled: false
openhab_enabled: false

# Pi-hole
pihole_with_traefik_enabled: false
pihole_without_traefik_enabled: false

# Books
calibre_enabled: false

Expand Down Expand Up @@ -332,6 +336,14 @@ traefik_docker_image: traefik:v1.7
traefik_data_directory: "{{ docker_home }}/traefik"
traefik_debug: "false"

###
### Pi-hole
###
pihole_data_directory: "{{ docker_home }}/pihole"
pihole_dns1: "1.1.1.1"
pihole_dns2: "8.8.8.8"
pihole_WEBPASSWORD: "byebyeads"

###
### Heimdall
###
Expand Down
8 changes: 8 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
when: (traefik_enabled | default(False))
tags: traefik

- import_tasks: tasks/pihole_with_traefik.yml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing indentation, build fails due to invalid yaml

when: (pihole_with_traefik_enabled | default(False))
tags: pihole_with_traefik

- import_tasks: tasks/pihole_without_traefik.yml
when: (pihole_without_traefik_enabled | default(False))
tags: pihole_without_traefik

- import_tasks: tasks/heimdall.yml
when: (heimdall_enabled | default(False))
tags: heimdall
Expand Down
9 changes: 8 additions & 1 deletion tasks/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@

# - name: Configure smartmontools

- name: pull Pi-hole image
docker_image:
name: pihole/pihole
state: present
when:
- ( pihole_with_traefik_enabled | default(False)) or ( pihole_without_traefik_enabled | default(False))

- name: "Set hostname to {{ ansible_nas_hostname }}"
hostname:
name: "{{ ansible_nas_hostname }}"
Expand All @@ -52,4 +59,4 @@
group: ansible-nas
mode: "u=rwX,g=rwX,o=rX"
recurse: false
loop: "{{ samba_shares }}"
loop: "{{ samba_shares }}"
50 changes: 50 additions & 0 deletions tasks/pihole_with_traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

---
- name: Pi-hole (with Traefik) Directories
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ pihole_data_directory }}/etc/pihole"
- "{{ pihole_data_directory }}/var/log/lighttpd"

- name: Pi-hole (with Traefik) Docker Container
docker_container:
name: pihole
image: pihole/pihole:latest
pull: false
volumes:
- "{{ pihole_data_directory }}/etc/pihole:/etc/pihole:rw"
- "{{ pihole_data_directory }}/etc/dnsmasq.d:/etc/dnsmasq.d:rw"
- "{{ pihole_data_directory }}/var/log:/var/log:rw"
ports:
- "53:53/tcp"
- "53:53/udp"
- "8182:80"
- "8183:443"
env:
DNS1: "{{ pihole_dns1 }}"
DNS2: "{{ pihole_dns2 }}"
ServerIP: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
WEBPASSWORD: "{{ pihole_WEBPASSWORD }}"
PROXY_LOCATION: "pihole"
TZ: "{{ ansible_nas_timezone }}"
VIRTUAL_HOST: "pihole.{{ ansible_nas_domain }}"
VIRTUAL_PORT: "80"
restart_policy: unless-stopped
labels:
traefik.enable: "true"
traefik.backend: "pihole"
traefik.port: "80"
traefik.frontend.rule: "HostRegexp:pihole.{{ ansible_nas_domain }},{catchall:.*}"
traefik.frontend.priority: "1"
traefik.frontend.headers.SSLRedirect: "true"
traefik.frontend.headers.STSSeconds: "315360000"
traefik.frontend.headers.browserXSSFilter: "true"
traefik.frontend.headers.contentTypeNosniff: "true"
traefik.frontend.headers.forceSTSHeader: "true"
traefik.frontend.headers.SSLHost: "{{ ansible_nas_domain }}"
traefik.frontend.headers.STSIncludeSubdomains: "true"
traefik.frontend.headers.STSPreload: "true"
traefik.frontend.headers.frameDeny: "true"
memory: 1g
32 changes: 32 additions & 0 deletions tasks/pihole_without_traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

---
- name: Pi-hole (without Traefik) Directories
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ pihole_data_directory }}/etc/pihole"
- "{{ pihole_data_directory }}/var/log/lighttpd"

- name: Pi-hole (without Traefik) Docker Container
docker_container:
name: pihole
image: pihole/pihole:latest
pull: false
volumes:
- "{{ pihole_data_directory }}/etc/pihole:/etc/pihole:rw"
- "{{ pihole_data_directory }}/etc/dnsmasq.d:/etc/dnsmasq.d:rw"
- "{{ pihole_data_directory }}/var/log:/var/log:rw"
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80"
- "443:443"
env:
DNS1: "{{ pihole_dns1 }}"
DNS2: "{{ pihole_dns2 }}"
ServerIP: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
WEBPASSWORD: "{{ pihole_WEBPASSWORD }}"
TZ: "{{ ansible_nas_timezone }}"
restart_policy: unless-stopped
memory: 1g
2 changes: 2 additions & 0 deletions templates/traefik/traefik.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ onDemand = false # create certificate when container is created
"nzbget.{{ ansible_nas_domain }}",
"ombi.{{ ansible_nas_domain }}",
"openhab.{{ ansible_nas_domain }}",
"organizr.{{ ansible_nas_domain }}",
"pihole.{{ ansible_nas_domain }}",
"plex.{{ ansible_nas_domain }}",
"portainer.{{ ansible_nas_domain }}",
"pyload.{{ ansible_nas_domain }}",
Expand Down