From 1580ac41d787d278c16e580803897f6204df252a Mon Sep 17 00:00:00 2001 From: vincent Date: Sat, 28 Nov 2020 16:17:16 +0100 Subject: [PATCH] add pihole image update --- defaults/main.yml | 3 ++- tasks/main.yml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 25b8be1..7a5d914 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -25,4 +25,5 @@ pihole_local_reverse_domain: '1.168.192.in-addr.arpa' pihole_local_resolver: pihole_dns_servers: - '127.0.0.1' - - '{{pihole_local_resolver | default(1.1.1.1)}}' \ No newline at end of file + - '{{pihole_local_resolver | default(1.1.1.1)}}' +pihole_update_container: false \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 696e6a7..439670a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,6 +14,13 @@ __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: + image: "{{ pihole_image_name }}" + force: yes + when: pihole_update_container == True + - name: "[docker] Setup the pi-hole docker container" docker_container: name: "{{ pihole_container_name }}" @@ -33,6 +40,12 @@ 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.