Skip to content

Commit 2775253

Browse files
Photon Traefik integration and tests
Co-authored-by: 33Fraise33 <33Fraise33@users.noreply.github.com>
1 parent f616ed8 commit 2775253

12 files changed

Lines changed: 81 additions & 30 deletions

File tree

molecule/dawarich/converge.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
dawarich_postgres_image: imresamu/postgis
1414
dawarich_services_network: molecule-services
1515
dawarich_dns_servers: []
16-
dawarich_photon_api_host: molecule-photon
17-
dawarich_photon_api_port: "2322"
18-
dawarich_photon_api_use_https: "false"
16+
dawarich_photon_api_host: photon.frai.se
17+
dawarich_photon_api_port: "443"
18+
dawarich_photon_api_use_https: "true"
1919
roles:
2020
- role: dawarich

molecule/dawarich/verify.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
- name: Assert Dawarich Photon configuration
4444
ansible.builtin.assert:
4545
that:
46-
- item.container.Config.Env is contains('PHOTON_API_HOST=molecule-photon')
47-
- item.container.Config.Env is contains('PHOTON_API_PORT=2322')
48-
- item.container.Config.Env is contains('PHOTON_API_USE_HTTPS=false')
46+
- item.container.Config.Env is contains('PHOTON_API_HOST=photon.frai.se')
47+
- item.container.Config.Env is contains('PHOTON_API_PORT=443')
48+
- item.container.Config.Env is contains('PHOTON_API_USE_HTTPS=true')
4949
loop: "{{ dawarich_photon_containers.results }}"

molecule/photon/cleanup.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
ansible.builtin.file:
1313
path: /tmp/molecule-photon-data
1414
state: absent
15+
16+
- name: Remove shared Traefik test network
17+
community.docker.docker_network:
18+
name: molecule-traefik
19+
state: absent

molecule/photon/converge.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,23 @@
1111
- http.server
1212
- "2322"
1313
photon_database_path: /tmp/molecule-photon-data
14-
photon_port: 12322
14+
photon_hostname: photon.test
15+
photon_network: molecule-traefik
16+
photon_healthcheck:
17+
test:
18+
- CMD-SHELL
19+
- >-
20+
python -c "from urllib.request import urlopen;
21+
assert urlopen('http://127.0.0.1:2322/').status == 200"
22+
interval: 5s
23+
timeout: 5s
24+
retries: 3
25+
start_period: 1s
26+
pre_tasks:
27+
- name: Create shared Traefik test network
28+
community.docker.docker_network:
29+
name: molecule-traefik
30+
driver: bridge
1531
roles:
1632
- role: photon
1733
tasks:

molecule/photon/verify.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
gather_facts: false
55
vars:
66
photon_database_path: /tmp/molecule-photon-data
7+
photon_network: molecule-traefik
78
tasks:
89
- name: Inspect Photon container
910
community.docker.docker_container_info:
@@ -14,11 +15,13 @@
1415
ansible.builtin.assert:
1516
that:
1617
- photon_container.container.State.Status == 'running'
18+
- photon_container.container.State.Health.Status == 'healthy'
1719
- photon_container.container.Config.Image == 'python:3.13-alpine'
1820
- photon_container.container.HostConfig.RestartPolicy.Name == 'always'
1921
- >-
20-
photon_container.container.HostConfig.PortBindings['2322/tcp'][0].HostPort
21-
== '12322'
22+
photon_container.container.HostConfig.PortBindings is none or
23+
photon_container.container.HostConfig.PortBindings | length == 0
24+
- photon_network in photon_container.container.NetworkSettings.Networks
2225
- >-
2326
photon_container.container.Mounts | selectattr('Destination', 'equalto',
2427
'/photon/photon_data') | list | length == 1
@@ -28,6 +31,12 @@
2831
map(attribute='Source') | first) == photon_database_path
2932
- photon_container.container.Config.Env is contains('PHOTON_UPDATE_STRATEGY=CONTINUOUS')
3033
- photon_container.container.Config.Env is contains('PHOTON_UPDATE_INTERVAL=3600')
34+
- photon_container.container.Config.Labels['traefik.enable'] == 'true'
35+
- photon_container.container.Config.Labels['traefik.docker.network'] == photon_network
36+
- photon_container.container.Config.Labels['traefik.http.routers.photon.rule'] == 'Host(`photon.test`)'
37+
- photon_container.container.Config.Labels['traefik.http.routers.photon.tls'] == 'true'
38+
- photon_container.container.Config.Labels['traefik.http.routers.photon.tls.certresolver'] == 'le'
39+
- photon_container.container.Config.Labels['traefik.http.services.photon.loadbalancer.server.port'] == '2322'
3140

3241
- name: Check Photon API endpoint from the container
3342
community.docker.docker_container_exec:

playbooks/group_vars/all.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ domain:
186186
answer: "{{ traefik.dco.ipv6 }}"
187187
- domain: time.unitix.be
188188
answer: "{{ traefik.dco.ip }}"
189-
# MEDIA
190-
- domain: "autobrr.frai.se"
189+
# MEDIA
190+
- domain: photon.frai.se
191+
answer: "{{ traefik.media.ipv6 }}"
192+
- domain: photon.frai.se
193+
answer: "{{ traefik.media.ip }}"
194+
- domain: "autobrr.frai.se"
191195
answer: "{{ traefik.media.ip }}"
192196
- domain: "autobrr.frai.se"
193197
answer: "{{ traefik.media.ipv6 }}"
@@ -565,4 +569,4 @@ authelia_oidc_clients:
565569
39306330636537383462656131366662643835663530316537626235636639373636316638303539
566570
33656462653730306433623231646663353136363534313365353236623636643335323761666632
567571
61663765396237356639333531353239316538383531356562643733346134316638366164326132
568-
61393833386366363732
572+
61393833386366363732

playbooks/host_vars/beokpdcovm01.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
dawarich_photon_api_host: 10.10.48.35
3-
dawarich_photon_api_port: "2322"
4-
dawarich_photon_api_use_https: "false"
2+
dawarich_photon_api_host: photon.frai.se
3+
dawarich_photon_api_port: "443"
4+
dawarich_photon_api_use_https: "true"
55

66
cloudflared:
77
docker_network: services

playbooks/host_vars/beokpdcovm02.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
---
22
photon_database_path: /media/photon
3+
photon_network: media
34

45
firewall_filter_input_host:
56
- comment: "Allow portainer_agent"
67
destination:
78
port: 9001
89
protocol: tcp
910
counter: true
10-
- comment: "Allow Photon from VM01"
11-
source:
12-
ip: "@VM01"
13-
destination:
14-
port: 2322
15-
protocol: tcp
16-
counter: true
17-
1811
firewall:
1912
sets: "{{ firewall_sets_all + firewall_sets_internal }}"
2013
filter:

roles/dawarich/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Supply `dawarich_database_password` and `dawarich_secret_key_base` through Ansib
1111
Reverse geocoding defaults to the public Photon service. Set
1212
`dawarich_photon_api_host`, `dawarich_photon_api_port`, and
1313
`dawarich_photon_api_use_https` to use a self-hosted Photon instance.
14+
In production Photon is exposed by media Traefik at `photon.frai.se:443` over
15+
HTTPS; Photon itself is managed separately on the media host.
1416

1517
Before deployment, define these variables in the target host or CI secret injection. Do not commit plaintext values:
1618

roles/photon/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Deploys [Photon](https://photon.komoot.io/) as a reverse-geocoding service for
44
Dawarich.
55

6+
Photon joins the media host's existing Traefik Docker network, configured by
7+
`photon_network` (the media network on VM02). It has no host-port publication
8+
and does not depend on the services VLAN. Traefik exposes the API as HTTPS at
9+
`photon_hostname` (`photon.frai.se`) and forwards requests to port 2322.
10+
611
`photon_database_path` controls the host directory mounted at
712
`/photon/photon_data`. Photon downloads and stores a large OpenStreetMap
813
database there on its first start. Place this directory on storage that is not
@@ -11,5 +16,5 @@ disk space while applying updates.
1116

1217
The container uses Photon’s recommended continuous update configuration:
1318
`PHOTON_UPDATE_STRATEGY=CONTINUOUS` and a `PHOTON_UPDATE_INTERVAL` of 3600
14-
seconds. Its API is published on `photon_port` (2322 by default); restrict
15-
network access with the host firewall.
19+
seconds. The pre-existing Traefik network must be available before deploying
20+
this role.

0 commit comments

Comments
 (0)