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

prepare rustdesk to be installed

This commit is contained in:
L3D 2024-02-18 03:57:44 +01:00
parent 051ce89ee4
commit ac97a54fe4
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
6 changed files with 151 additions and 0 deletions

View file

@ -1,3 +1,19 @@
--- ---
rustdesk__version: 'latest'
rustdesk__user: 'rustdesk'
rustdesk__group: "{{ rustdesk__user }}"
rustdesk__home: '/var/lib/rustdesk'
rustdesk__user_home: "{{ rustdesk__home }}"
rustdesk__ignore_version_mismatch: false
rustdesk__require_key: true
rustdesk__relay_server_domain: "{{ ansible_fqdn }}"
rustdesk__relay_server_port: '21117'
rustdesk__signal_server_port: '21116'
rustdesk__hbbr_executable_path: '/usr/local/bin/hbbr'
rustdesk__hbbs_executable_path: '/usr/local/bin/hbbs'
rustdesk__rustdesk_utils_executable_path: '/usr/local/bin/rustdesk-utils'
# should we do a version check? (recomended) # should we do a version check? (recomended)
submodules_versioncheck: false submodules_versioncheck: false

18
tasks/create_user.yml Normal file
View file

@ -0,0 +1,18 @@
---
- name: "Create rustdesk Group"
become: true
ansible.builtin.group:
name: "{{ rustdesk__group }}"
system: true
state: "present"
- name: "Create rustdesk user"
become: true
ansible.builtin.user:
name: "{{ rustdesk__user }}"
comment: "rustdesk user"
group: "{{ rustdesk__group }}"
groups: "{{ rustdesk__groups | default(omit) }}"
home: "{{ rustdesk__user_home }}"
shell: "/usr/sbin/nologin"
system: true

15
tasks/directory.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: "Create config and data directory"
become: true
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ rustdesk__user }}"
group: "{{ rustdesk__group }}"
mode: 'u=rwX,g=rX,o='
loop:
- "{{ rustdesk__home }}"
- "{{ rustdesk__user_home }}"
notify:
- 'systemctl restart rustdesk-hbbs'
- 'systemctl restart rustdesk-hbbr'

View file

@ -3,3 +3,24 @@
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: 'versioncheck.yml' file: 'versioncheck.yml'
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: Gather versioning information
ansible.builtin.include_tasks:
file: "set_rustdesk_version.yml"
- name: Create homebox user and group
ansible.builtin.include_tasks:
file: 'create_user.yml'
- name: Install or Update homebox
ansible.builtin.include_tasks:
file: 'install.yml'
- name: Create directories
ansible.builtin.include_tasks:
file: 'directory.yml'
# - name: Setup homebox systemd service
# ansible.builtin.include_tasks:
# file: 'install_systemd.yml'
# when: ansible_service_mgr == "systemd"

View file

@ -0,0 +1,69 @@
---
- name: "Check rustdesk hbbr installed version"
ansible.builtin.shell: "set -eo pipefail; {{ rustdesk__hbbr_executable_path }} --version | cut -d ' ' -f2"
args:
executable: /bin/bash
register: rustdesk__hbbr_active_version
changed_when: false
failed_when: false
- name: "Check rustdesk hbbs installed version"
ansible.builtin.shell: "set -eo pipefail; {{ rustdesk__hbbs_executable_path }} --version | cut -d ' ' -f2"
args:
executable: /bin/bash
register: rustdesk__hbbs_active_version
changed_when: false
failed_when: false
- name: Fail if versions are not identical
ansible.builtin.fail:
msg: |
Versios of rustdesk-server components mismatch.
{{ rustdesk__hbbr_executable_path }}: rustdesk__hbbr_active_version
{{ rustdesk__hbbs_executable_path }}: rustdesk__hbbs_active_version
You can Ignore it by running ansible again with
-e rustdesk__ignore_version_mismatch=true
when:
- rustdesk__hbbr_active_version != rustdesk__hbbs_active_version
- rustdesk__ignore_version_mismatch | bool
- name: "Determine 'latest' version release"
when: rustdesk__version == "latest"
block:
- name: "Get latest rustdesk release metadata"
ansible.builtin.uri:
url: https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest
return_content: true
register: rustdesk__remote_metadata
become: false
when: not ansible_check_mode
- name: "Fail if running in check mode without versions set."
ansible.builtin.fail:
msg: |
"You are running this playbook in check mode:
Please set the rustdesk version with the variable 'rustdesk__version', because the URI module cannot detect the latest version in this mode."
when: ansible_check_mode and (rustdesk__version == 'latest' or rustdesk__version == 'present')
- name: "Set fact latest rustdesk release"
ansible.builtin.set_fact:
rustdesk__remote_version: "{{ rustdesk__remote_metadata.json.tag_name }}"
when: not ansible_check_mode
- name: "Set rustdesk version target (latest)"
ansible.builtin.set_fact:
rustdesk__version_target: "{{ rustdesk__remote_version }}"
when: not ansible_check_mode
- name: "Set rustdesk version target {{ rustdesk__version }}"
ansible.builtin.set_fact:
rustdesk__version_target: "{{ rustdesk__version }}"
when: rustdesk__version != "latest"
- name: 'Assert that remote version is higher'
ansible.builtin.assert:
that:
- rustdesk__hbbr_active_version is version(rustdesk__remote_version, 'lt')
fail_msg: ERROR - Remote version is lower then current version!
when:
- rustdesk__version == "latest" and rustdesk__hbbr_active_version.stderr == ""

View file

@ -1,4 +1,16 @@
--- ---
rustdesk__go_arch_map:
i386: 'i386'
x86_64: 'amd64'
aarch64: 'arm64v8'
armv7l: 'armv7'
armv6l: 'armv7'
armv5l: 'armv7'
rustdesk__arch: "{{ rustdesk__go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
rustdesk__dl_filename: "rustdesk-server-{{ ansible_system }}-{{ rustdesk__arch }}"
rustdesk__dl_url: "https://github.com/rustdesk/rustdesk-server/releases/download/{{ rustdesk__version_target }}/{{ rustdesk__dl_filename }}.zip"
# versionscheck # versionscheck
playbook_version_number: 2 playbook_version_number: 2
playbook_version_path: 'role_l3d.rustdesk.version' playbook_version_path: 'role_l3d.rustdesk.version'