/
/
/
Ansible role that deploys my connectivity device.
1---
2# Connectivity Services - Pull latest images and recreate containers
3#
4# Usage via update-services.yml:
5# All connectivity: ansible-playbook update-services.yml --limit connectivity_servers
6# Single service: ansible-playbook update-services.yml --limit connectivity_servers --tags wireguard
7
8- name: Update WireGuard
9 when: connectivity_wireguard_enabled | default(true)
10 tags: [wireguard, vpn]
11 block:
12 - name: "WireGuard - Pull latest images and recreate"
13 community.docker.docker_compose:
14 project_src: "{{ connectivity_docker_base_path }}/wireguard"
15 pull: yes
16 state: present
17 register: wireguard_update
18
19 - name: "WireGuard - Report update status"
20 debug:
21 msg: "WireGuard: {{ 'updated' if wireguard_update.changed else 'already up to date' }}"
22
23- name: Update Nginx Proxy Manager
24 when: connectivity_nginx_proxy_enabled | default(true)
25 tags: [nginx-proxy, proxy]
26 block:
27 - name: "Nginx Proxy Manager - Pull latest images and recreate"
28 community.docker.docker_compose:
29 project_src: "{{ connectivity_docker_base_path }}/nginx-proxy"
30 pull: yes
31 state: present
32 register: nginx_update
33
34 - name: "Nginx Proxy Manager - Report update status"
35 debug:
36 msg: "Nginx Proxy Manager: {{ 'updated' if nginx_update.changed else 'already up to date' }}"
37
38- name: Update Pi-hole
39 when: connectivity_dns_stack_enabled | default(true)
40 tags: [pihole, dns]
41 block:
42 - name: "Pi-hole - Pull latest images and recreate"
43 community.docker.docker_compose:
44 project_src: "{{ connectivity_docker_base_path }}/pihole"
45 pull: yes
46 state: present
47 register: pihole_update
48
49 - name: "Pi-hole - Report update status"
50 debug:
51 msg: "Pi-hole: {{ 'updated' if pihole_update.changed else 'already up to date' }}"
52
53- name: Update Unbound
54 when: connectivity_dns_stack_enabled | default(true)
55 tags: [unbound, dns]
56 block:
57 - name: "Unbound - Pull latest images and recreate"
58 community.docker.docker_compose:
59 project_src: "{{ connectivity_docker_base_path }}/unbound"
60 pull: yes
61 state: present
62 register: unbound_update
63
64 - name: "Unbound - Report update status"
65 debug:
66 msg: "Unbound: {{ 'updated' if unbound_update.changed else 'already up to date' }}"
67
68- name: Prune unused Docker images
69 tags: [cleanup, prune]
70 community.docker.docker_prune:
71 images: true
72 images_filters:
73 dangling: "true"
74 register: prune_result
75
76- name: Report cleanup
77 tags: [cleanup, prune]
78 debug:
79 msg: "Pruned {{ prune_result.images | default([]) | length }} dangling image(s), reclaimed {{ prune_result.images_space_reclaimed | default(0) | human_readable }}"
80 when: prune_result.images | default([]) | length > 0
81