2020-07-04 14:17:17 +00:00
|
|
|
---
|
2020-07-04 18:29:43 +00:00
|
|
|
# tasks file for ansible-pihole
|
|
|
|
|
2020-07-05 10:12:10 +00:00
|
|
|
- name: Stop bind service
|
|
|
|
service:
|
|
|
|
name: named
|
|
|
|
state: stopped
|
|
|
|
enabled: no
|
|
|
|
failed_when: no
|
|
|
|
|
2020-07-05 10:11:55 +00:00
|
|
|
- name: "Set the __docker_pihole_admin_password fact"
|
|
|
|
set_fact:
|
|
|
|
__docker_pihole_random_password: "{{ lookup('password', '/dev/null chars=ascii_letters,digits') }}"
|
|
|
|
__docker_pihole_admin_password: "{{ pihole_admin_password | default(__docker_pihole_random_password) }}"
|
2020-07-04 18:29:43 +00:00
|
|
|
|
2020-07-05 10:11:55 +00:00
|
|
|
- name: "[docker] Setup the pi-hole docker container"
|
|
|
|
docker_container:
|
|
|
|
name: "{{ pihole_container_name }}"
|
|
|
|
image: "{{ pihole_image_name }}"
|
|
|
|
state: started
|
|
|
|
restart: yes
|
|
|
|
restart_policy: 'unless-stopped'
|
|
|
|
volumes: "{{ pihole_volumes }}"
|
|
|
|
published_ports: "{{ pihole_port }}"
|
|
|
|
env:
|
|
|
|
TZ: "{{pihole_timezone }}"
|
|
|
|
WEBPASSWORD: "{{ __docker_pihole_admin_password }}"
|
|
|
|
DNS1: "{{pihole_forwarder1}}"
|
|
|
|
DNS2: "{{pihole_forwarder2}}"
|
|
|
|
capabilities:
|
2020-07-04 18:29:43 +00:00
|
|
|
- NET_ADMIN
|
2020-07-05 10:11:55 +00:00
|
|
|
dns_servers: "{{ pihole_dns_servers }}"
|
2020-07-05 10:12:10 +00:00
|
|
|
become: yes
|
2020-07-05 10:11:55 +00:00
|
|
|
|
|
|
|
- name: "add custom dnsmask file"
|
|
|
|
template:
|
2020-07-05 10:12:10 +00:00
|
|
|
dest: "{{pihole_host_dir_dnsmasqd}}/02-localresolver.conf" # required. Location to render the template to on the remote machine.
|
2020-07-05 10:11:55 +00:00
|
|
|
src: 02-localresolver.conf.j2 # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
|
|
|
|
when: pihole_local_resolver is defined
|
|
|
|
notify: restart pihole container
|
2020-07-05 10:12:10 +00:00
|
|
|
become: yes
|