Add the RustDesk server playbook
This commit is contained in:
1 parent
fc31504f57
commit
d248675643
7 files changed
+273
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
# Handlers for Caddy role
|
||||
- name: Reload Caddy configuration
|
||||
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
|
||||
listen: "Reload Caddy"
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Read current Caddyfile
|
||||
ansible.builtin.slurp:
|
||||
path: "{{ caddyfile_path }}"
|
||||
register: caddyfile_raw
|
||||
|
||||
- name: Decode Caddyfile content
|
||||
set_fact:
|
||||
caddyfile_content: "{{ caddyfile_raw['content'] | b64decode }}"
|
||||
|
||||
- name: Check if snippet already exists
|
||||
set_fact:
|
||||
snippet_present: "{{ snippet_block in caddyfile_content }}"
|
||||
|
||||
- name: Add snippet if missing
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ caddyfile_path }}"
|
||||
marker: "# {mark} Ansible managed Caddy snippet for {{ host }}"
|
||||
block: "{{ snippet_block }}"
|
||||
create: yes
|
||||
when: not snippet_present
|
||||
notify: "Reload Caddy"
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
# Caddy is the only thing that talks to hbbs/hbbr, so it joins the network the
|
||||
# RustDesk container lives on and can resolve it by container name.
|
||||
- name: "Ensure {{ docker_network }} Docker network exists"
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ caddy_container }}"
|
||||
appends: yes
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
# Tasks for the RustDesk server role
|
||||
- name: Pull RustDesk server image
|
||||
docker_image:
|
||||
name: "{{ image_name }}:{{ image_version }}"
|
||||
source: pull
|
||||
force_source: yes
|
||||
|
||||
- name: Ensure the RustDesk data directory exists
|
||||
file:
|
||||
path: "{{ data_location }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
# One container runs both hbbs and hbbr under s6. Its WebSocket ports are left
|
||||
# unpublished: Caddy reaches them over the shared Docker network, so clients
|
||||
# only ever connect to 443.
|
||||
- name: Create the RustDesk server container
|
||||
docker_container:
|
||||
name: "{{ docker_container }}"
|
||||
image: "{{ image_name }}:{{ image_version }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env: "{{ rustdesk_env }}"
|
||||
published_ports: "{{ rustdesk_published_ports }}"
|
||||
volumes:
|
||||
- "{{ data_location }}:/data"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
|
||||
- name: Wait for hbbs to write out its key pair
|
||||
ansible.builtin.wait_for:
|
||||
path: "{{ data_location }}/id_ed25519.pub"
|
||||
timeout: 60
|
||||
register: rustdesk_key_file
|
||||
failed_when: false
|
||||
|
||||
- name: Read the public key clients have to be configured with
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ data_location }}/id_ed25519.pub"
|
||||
register: rustdesk_public_key
|
||||
when: rustdesk_key_file is succeeded
|
||||
|
||||
- name: Show the connection details
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
RustDesk clients: ID Server {{ host }}, API Server https://{{ host }},
|
||||
enable "Use WebSocket", and use
|
||||
{{ rustdesk_public_key['content'] | b64decode | trim }} as the key.
|
||||
when: rustdesk_public_key is not skipped
|
||||
Reference in new issue
Block a user