1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_rustdesk.git synced 2024-08-16 10:19:48 +02:00

install rustdesk and create systemd units

This commit is contained in:
L3D 2024-02-18 03:58:07 +01:00
parent ac97a54fe4
commit 23afb93340
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
4 changed files with 173 additions and 0 deletions

75
tasks/install.yml Normal file
View file

@ -0,0 +1,75 @@
---
- name: Dependency block
block:
- name: Update apt cache
become: true
ansible.builtin.apt:
cache_valid_time: 3600
update_cache: true
register: _pre_update_apt_cache
until: _pre_update_apt_cache is succeeded
when:
- ansible_pkg_mgr == "apt"
- name: Install rustdesk block
when: (not ansible_check_mode and (rustdesk__hbbr_active_version.stdout != rustdesk__version_target))
block:
- name: Create temporary download directory
become: true
ansible.builtin.tempfile:
state: directory
suffix: dl_hbx
register: rustdesk__dl_dir
- name: Download and extract rustdesk
become: true
ansible.builtin.unarchive:
creates: "{{ rustdesk__dl_dir.path }}/{{ rustdesk__arch }}"
dest: "{{ rustdesk__dl_dir.path }}"
remote_src: true
group: "{{ rustdesk__group }}"
owner: "{{ rustdesk__user }}"
src: "{{ rustdesk__dl_url }}"
register: _download_archive
until: _download_archive is succeeded
retries: 5
delay: 2
- name: Propagate rustdesk hbbr binary
become: true
ansible.builtin.copy:
src: "{{ rustdesk__dl_dir.path }}/{{ rustdesk__arch }}/hbbr"
remote_src: true
dest: "{{ rustdesk__hbbr_executable_path }}"
mode: 0755
owner: root
group: root
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'
- name: Propagate rustdesk hbbs binary
become: true
ansible.builtin.copy:
src: "{{ rustdesk__dl_dir.path }}/{{ rustdesk__arch }}/hbbs"
remote_src: true
dest: "{{ rustdesk__hbbs_executable_path }}"
mode: 0755
owner: root
group: root
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'
- name: Propagate rustdesk rustdesk-utils binary
become: true
ansible.builtin.copy:
src: "{{ rustdesk__dl_dir.path }}/{{ rustdesk__arch }}/rustdesk-utils"
remote_src: true
dest: "{{ rustdesk__rustdesk_utils_executable_path }}"
mode: 0755
owner: root
group: root
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'

54
tasks/install_systemd.yml Normal file
View file

@ -0,0 +1,54 @@
---
- name: "Setup systemd service for RustDesk Signal Server"
become: true
ansible.builtin.template:
src: 'rustdesk-hbbs.service.j2'
dest: '/lib/systemd/system/rustdesk-hbbs.service'
owner: 'root'
group: 'root'
mode: '0644'
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl daemon-reload'
- name: "Setup systemd service for RustDesk Relay Server"
become: true
ansible.builtin.template:
src: 'rustdesk-hbbr.service.j2'
dest: '/lib/systemd/system/rustdesk-hbbr.service'
owner: 'root'
group: 'root'
mode: '0644'
notify:
- 'systemctl restart rustdesk-hbbr'
- 'systemctl daemon-reload'
- name: "Reload systemd"
become: true
ansible.builtin.systemd:
daemon_reload: true
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'
- name: "Start and enable rustdesk signal server"
become: true
ansible.builtin.systemd:
name: 'rustdesk-hbbs'
state: 'started'
enabled: true
when: ansible_service_mgr == "systemd"
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'
- name: "Start and enable rustdesk relay server"
become: true
ansible.builtin.systemd:
name: 'rustdesk-hbbr'
state: 'started'
enabled: true
when: ansible_service_mgr == "systemd"
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'

View file

@ -0,0 +1,22 @@
{{ ansible_managed | comment }}
[Unit]
Description=Rustdesk Relay Server
After=network.target rustdesk-hbbs.service
[Service]
Type=simple
{% if rustdesk__require_key | bool %}
ExecStart={{ rustdesk__hbbr_executable_path }} --port {{ rustdesk__relay_server_port }} -k _
{% else %}
ExecStart={{ rustdesk__hbbr_executable_path }} --port {{ rustdesk__relay_server_port }}
{% endif %}
WorkingDirectory={{ rustdesk__home }}
User={{ rustdesk__user }}
Group={{ rustdesk__group }}
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,22 @@
{{ ansible_managed | comment }}
[Unit]
Description=Rustdesk Signal Server
After=network.target
Before=rustdesk-hbbr.service
[Service]
Type=simple
{% if rustdesk__require_key | bool %}
ExecStart={{ rustdesk__hbbs_executable_path }} --port {{ rustdesk__signal_server_port }} --relay-servers {{ rustdesk__relay_server_domain }}:{{ rustdesk__relay_server_port }} --key _
{% else %}
ExecStart={{ rustdesk__hbbs_executable_path }} --port {{ rustdesk__signal_server_port }} --relay-servers {{ rustdesk__relay_server_domain }}:{{ rustdesk__relay_server_port }}
{% endif %}
WorkingDirectory={{ rustdesk__home }}
User={{ rustdesk__user }}
Group={{ rustdesk__group }}
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
[Install]
WantedBy=multi-user.target