add rustdesk role

This commit is contained in:
Sergey Malyuk
2025-12-17 11:20:05 +03:00
parent 87cf29448b
commit 7fd2c6d60a
25 changed files with 458 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
---
- name: "Check hbbr version"
register: hbbr_output
changed_when: false
ansible.builtin.command:
cmd: "/opt/rustdesk-server/amd64/hbbr --version"
- name: "Check if the version of hbbr is the expected one"
ansible.builtin.assert:
that: "hbbr_output.stdout == 'hbbr {{ rustdesk_server_version }}'"
success_msg: "hbbr is installed and is the correct version"
fail_msg: "hbbr is either not installed or does not match the target version"
- name: "Check hbbs version"
register: hbbs_output
changed_when: false
ansible.builtin.command:
cmd: "/opt/rustdesk-server/amd64/hbbs --version"
- name: "Check if the version of hbbs is the expected one"
ansible.builtin.assert:
that: "hbbs_output.stdout == 'hbbs {{ rustdesk_server_version }}'"
success_msg: "hbbs is installed and is the correct version"
fail_msg: "hbbs is either not installed or does not match the target version"

View File

@@ -0,0 +1,30 @@
---
- name: "Install curl for generate-rustdesk-bat.sh script on Debian family"
when: ansible_os_family == "Debian"
ansible.builtin.apt:
name: curl
state: present
update_cache: true
- name: "Install curl for generate-rustdesk-bat.sh script on RedHat family"
when: ansible_os_family == "RedHat"
ansible.builtin.dnf:
name: curl
state: present
- name: "Install curl for generate-rustdesk-bat.sh script on FreeBSD family"
when: ansible_os_family == "FreeBSD"
community.general.pkgng:
name: curl
state: present
- name: "Install curl for generate-rustdesk-bat.sh script on other OS"
when:
- ansible_os_family != "Debian"
- and ansible_os_family != "RedHat"
- and ansible_os_family != "FreeBSD"
ansible.builtin.package:
name: curl
state: present
update_cache: true

View File

@@ -0,0 +1,30 @@
---
- name: "Install unzip for unarchiving the binaries archive on Debian family"
when: ansible_os_family == "Debian"
ansible.builtin.apt:
name: unzip
state: present
update_cache: true
- name: "Install unzip for unarchiving the binaries archive on RedHat family"
when: ansible_os_family == "RedHat"
ansible.builtin.dnf:
name: unzip
state: present
- name: "Install unzip for unarchiving the binaries archive on FreeBSD family"
when: ansible_os_family == "FreeBSD"
community.general.pkgng:
name: unzip
state: present
- name: "Install unzip for unarchiving the binaries archive on other OS"
when:
- ansible_os_family != "Debian"
- and ansible_os_family != "RedHat"
- and ansible_os_family != "FreeBSD"
ansible.builtin.package:
name: unzip
state: present
update_cache: true

View File

@@ -0,0 +1,67 @@
---
- name: "Install unzip"
ansible.builtin.include_tasks: install-unzip.yml
- name: "Install curl"
ansible.builtin.include_tasks: install-curl.yml
- name: "Add user rustdesk"
ansible.builtin.user:
name: "rustdesk"
shell: /usr/sbin/nologin
create_home: false
# Rustdesk uses /opt/rustdesk-server/lib/ as a working directory. When it's first started it generates key pairs and puts them in lib directory
- name: "Create lib directory"
ansible.builtin.file:
path: /opt/rustdesk-server/lib/
state: directory
mode: "0755"
owner: "rustdesk"
group: "rustdesk"
- name: "Download rustdesk-client"
ansible.builtin.get_url:
url: "https://github.com/rustdesk/rustdesk/releases/download/{{ rustdesk_client_version }}/rustdesk-{{ rustdesk_client_version }}-x86_64.exe"
dest: /opt/rustdesk-server/lib/rustdesk-client.exe
mode: "0644"
owner: "rustdesk"
group: "rustdesk"
- name: "Copy generate-rustdesk-exe.sh to target machine"
ansible.builtin.copy:
src: "generate-rustdesk-exe.sh"
dest: /opt/rustdesk-server/
mode: "0755"
owner: "rustdesk"
group: "rustdesk"
- name: "Install rustdesk"
block:
- name: "Check rustdesk version"
ansible.builtin.include_tasks: check-rustdesk-version.yml
rescue:
- name: "Download and unarchive the binaries"
ansible.builtin.unarchive:
src: "https://github.com/rustdesk/rustdesk-server/releases/download/{{ rustdesk_server_version }}/rustdesk-server-linux-amd64.zip"
dest: /opt/rustdesk-server/
remote_src: true
- name: "Copy rustdesk-hbbr.service to /etc/systemd/system/"
notify: "Start and enable rustdesk-hbbr.service"
ansible.builtin.copy:
src: "rustdesk-hbbr.service"
dest: /etc/systemd/system/
mode: "0755"
owner: "rustdesk"
group: "rustdesk"
- name: "Copy rustdesk-hbbs.service to /etc/systemd/system/"
notify: "Start and enable rustdesk-hbbs.service"
ansible.builtin.copy:
src: "rustdesk-hbbs.service"
dest: /etc/systemd/system/
mode: "0755"
owner: "rustdesk"
group: "rustdesk"