--- # tasks file for ansible-pihole - name: Stop bind service service: name: named state: stopped enabled: no failed_when: no become: yes - 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) }}" - name: update image if needed docker_image: name: "{{ pihole_image_name }}" force_source: yes source: pull when: pihole_update_container == True - 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: - NET_ADMIN dns_servers: "{{ pihole_dns_servers }}" become: yes - name: cleanup old image docker_prune: images: yes when: pihole_update_container == True - name: "add custom dnsmask file" template: dest: "{{pihole_host_dir_dnsmasqd}}/02-localresolver.conf" # required. Location to render the template to on the remote machine. 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 become: yes