This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
pi-ansible/roles/docker_services/tasks/services/pihole.yml

42 lines
1 KiB
YAML
Raw Normal View History

2023-05-28 15:58:12 +00:00
# vim: ft=yaml.ansible
---
- name: Create Pi-hole volume directories
ansible.builtin.file:
name: "{{ services.pihole.volume }}/{{ dir }}"
owner: root
mode: u=rwx,g=rx,o=rx
state: directory
loop:
- pihole
- dnsmasq.d
loop_control:
loop_var: dir
- name: Create Docker network for Pi-hole
community.docker.docker_network:
name: pi-hole
state: present
- name: Deploy Pi-hole Docker container
community.docker.docker_container:
name: pi-hole
state: "{{ 'absent' if stop is defined and stop else 'started' }}"
restart: "{{ stop is undefined or not stop }}"
image: pihole/pihole:{{ services.pihole.version }}
restart_policy: always
default_host_ip: ''
networks:
- name: pi-hole
env:
DNSMASQ_LISTENING: all
TZ: "{{ timezone }}"
volumes:
- "{{ services.pihole.volume }}/pihole:/etc/pihole:rw"
- "{{ services.pihole.volume }}/dnsmasq.d:/etc/dnsmasq.d:rw"
published_ports:
- 53:53/tcp
- 53:53/udo
- 81:80/tcp
capabilities:
- net_admin