Skip to content

Commit

Permalink
Generate tailscale items on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
claha committed Nov 13, 2023
1 parent 535600b commit fb4dc45
Show file tree
Hide file tree
Showing 4 changed files with 499 additions and 531 deletions.
3 changes: 3 additions & 0 deletions .github/actions/setup-ansible/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ runs:
healthchecks_backup_zigbee2mqtt_ping_url: ci
healthchecks_secret_key: ci
homeassistant_static_template_sensors: []
homepage_tailscale_devices:
json:
devices: []
letsencrypt_email: ci
letsencrypt_provider: ci
mqtt_server: ci
Expand Down
10 changes: 10 additions & 0 deletions roles/homepage/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
---
- name: Fetch list of tailscale devices
delegate_to: localhost
ansible.builtin.uri:
url: "https://api.tailscale.com/api/v2/tailnet/-/devices"
method: GET
headers:
Authorization: "Bearer {{ tailscale_key }}"
register: homepage_tailscale_devices
when: homepage_tailscale_devices is undefined

- name: Create docker compose service
ansible.builtin.include_role:
name: docker_compose_service
Expand Down
42 changes: 4 additions & 38 deletions roles/homepage/templates/services.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,11 @@
icon: https://github.com/MauriceNino/dashdot/blob/main/apps/docs/static/img/logo512.png?raw=true

- Tailscale:
- RPi4:
{% for device in homepage_tailscale_devices.json.devices %}
- {{ device.hostname }}:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_rpi4 | default()}}
deviceid: {{ device.nodeId }}
key: {{ tailscale_key | default()}}
- RPi3:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_rpi3 | default() }}
key: {{ tailscale_key | default() }}
- RPi2:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_rpi2 | default() }}
key: {{ tailscale_key | default() }}
- RPi0:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_rpi0 | default() }}
key: {{ tailscale_key | default() }}
- OCI 0:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_oci0 | default() }}
key: {{ tailscale_key | default() }}
- OCI 1:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_oci1 | default() }}
key: {{ tailscale_key | default() }}
- OCI A1:
icon: tailscale
widget:
type: tailscale
deviceid: {{ tailscale_id_ocia1 | default() }}
key: {{ tailscale_key | default() }}
{% endfor %}
Loading

0 comments on commit fb4dc45

Please sign in to comment.