Files
vps/ansible/roles/rustdesk/tasks/main.yml
T
windyboy 035587e3bf feat(rustdesk): onboard self-hosted RustDesk server on hk2
Deploy hbbs + hbbr via a safe-by-default Ansible role (playbooks/rustdesk.yml):
with rustdesk_confirm=false it only reports whether compose.yml matches live
state and refuses to recreate the stack; with rustdesk_confirm=true it deploys
and recreates. The relay assert rejects the known-bad hk2.wsvc.info hostname.

Add health profiles rustdesk (hbbs/hbbr health, relay DNS) and hk2aux (co-located
traefik/adguard/remark42 on hk2), plus the rustdesk-health runbook and AGENTS.md
entry. Server image pinned rustdesk/rustdesk-server:1.1.14.
2026-08-12 21:16:30 +08:00

86 lines
2.4 KiB
YAML

---
# Deploy/reconcile the self-hosted RustDesk server (hbbs + hbbr).
# Idempotent: deploys the declared compose file; only recreates the stack with
# explicit confirmation.
- name: Validate relay address is set and not the known-bad value
ansible.builtin.assert:
that:
- rustdesk_relay | length > 0
- "'hk2.wsvc.info' not in rustdesk_relay"
fail_msg: >-
rustdesk_relay must be a resolvable relay address. The known-bad
'hk2.wsvc.info' has no DNS record and must not be used.
- name: Ensure compose project directory exists
ansible.builtin.file:
path: "{{ rustdesk_compose_dir }}"
state: directory
owner: windy
group: root
mode: "0755"
- name: Deploy compose file
ansible.builtin.template:
src: compose.yml.j2
dest: "{{ rustdesk_compose_dir }}/compose.yml"
owner: windy
group: windy
mode: "0644"
register: rustdesk_compose_deployed
- name: Report no change needed
ansible.builtin.debug:
msg: "compose.yml already matches declared state; no change needed."
when: not rustdesk_compose_deployed.changed
- name: Refuse to recreate without explicit confirmation
ansible.builtin.fail:
msg: >-
compose.yml differs from declared state but rustdesk_confirm is not true.
Supply rustdesk_confirm=true to deploy the file and recreate the stack.
when:
- rustdesk_compose_deployed.changed
- not (rustdesk_confirm | bool)
- not ansible_check_mode
- name: Apply compose stack
ansible.builtin.command:
argv:
- docker
- compose
- --project-directory
- "{{ rustdesk_compose_dir }}"
- up
- -d
when:
- rustdesk_compose_deployed.changed
- rustdesk_confirm | bool
changed_when: true
register: rustdesk_apply
- name: Verify hbbs relay command
ansible.builtin.command:
argv:
- docker
- inspect
- hbbs
- --format
- '{{ "{{" }}json .Config.Cmd{{ "}}" }}'
register: rustdesk_hbbs_cmd
changed_when: false
when:
- rustdesk_compose_deployed.changed
- rustdesk_confirm | bool
- not ansible_check_mode
- name: Assert hbbs advertises the declared relay
ansible.builtin.assert:
that:
- "'{{ rustdesk_relay }}' in rustdesk_hbbs_cmd.stdout"
fail_msg: "hbbs is not advertising the declared relay {{ rustdesk_relay }}."
when:
- rustdesk_compose_deployed.changed
- rustdesk_confirm | bool
- not ansible_check_mode