roles-ansible / ansible_role_rustdesk

Ansible role to Setup and configure your own rustdesk Server
https://galaxy.ansible.com/ui/standalone/roles/roles-ansible/rustdesk/
MIT License
3 stars 0 forks source link

Is there a rollback playbook for ansible_role_rustdesk? #7

Closed quoterbox closed 3 months ago

quoterbox commented 3 months ago

Hello! Do you have a rollback playbook for this one role https://github.com/roles-ansible/ansible_role_rustdesk ?

DO1JLR commented 3 months ago

Hey @quoterbox

Sorry, I don't have a role or playbook for that yet. Usually I spawn new virtual instances for services like that so I don't really have the need for it. I would guess you have to delete the /var/lib/rustdesk folders, config and the rustdesk binarys, but I did not test that...

quoterbox commented 3 months ago

Hey @quoterbox

Sorry, I don't have a role or playbook for that yet. Usually I spawn new virtual instances for services like that so I don't really have the need for it. I would guess you have to delete the /var/lib/rustdesk folders, config and the rustdesk binarys, but I did not test that...

I thought so. Yes, reinstalling the virtual server is an option, I agree. I just thought I couldn't find a rollback playbook in the code. Thanks for the useful playbook!

If I were to draft a rollback playbook for your role, could you guide me on what it would look like?

  1. Stop the rustdesk-hbbs and rustdesk-hbbr services
  2. Remove the rustdesk group and user
  3. Delete the /var/lib/rustdesk directory

Do I need to perform any additional actions? For example, should I stop port listening or delete the directories: rustdeskhbbr_executable_path: '/usr/local/bin/hbbr' rustdeskhbbs_executable_path: '/usr/local/bin/hbbs' rustdesk__rustdesk_utils_executable_path: '/usr/local/bin/rustdesk-utils

I'm not a Linux user, so I might ask silly questions)

DO1JLR commented 3 months ago

After stopping the systemd services you probavly should delete them too since this role is deploying systemd files in https://github.com/roles-ansible/ansible_role_rustdesk/blob/main/tasks/install_systemd.yml

So, a more complete list could be:

  1. Stop systemd services
  2. Delete systemd services
  3. delete /var/lib/rustdesk directory
  4. delete rustdesk binarys (/usr/local/bin/hbbr, /usr/local/bin/hbbs and /usr/local/bin/rustdesk-utils)
  5. Delete user & group
quoterbox commented 3 months ago

Thank you! That's useful

quoterbox commented 3 months ago

I've made a simple rollback playbook; maybe it will be useful for someone

---
- name: "Rollback RustDesk server setup"
  hosts: www
  become: yes
  vars_files:
    - ../group_vars/main.yml
  tasks:
    - name: "Gather service facts"
      ansible.builtin.service_facts:

    - name: "Check if rustdesk-hbbr service exists"
      set_fact:
        hbbr_service_exists: "{{ 'rustdesk-hbbr.service' in ansible_facts.services }}"

    - name: "Stop and disable rustdesk-hbbr service"
      ansible.builtin.systemd:
        name: "rustdesk-hbbr"
        state: stopped
        enabled: no
      when: hbbr_service_exists
      ignore_errors: true

    - name: "Check if rustdesk-hbbs service exists"
      set_fact:
        hbbs_service_exists: "{{ 'rustdesk-hbbs.service' in ansible_facts.services }}"

    - name: "Stop and disable rustdesk-hbbs service"
      ansible.builtin.systemd:
        name: "rustdesk-hbbs"
        state: stopped
        enabled: no
      when: hbbs_service_exists
      ignore_errors: true

    - name: "Remove rustdesk-hbbr service file"
      ansible.builtin.file:
        path: "/lib/systemd/system/rustdesk-hbbr.service"
        state: absent
      ignore_errors: true

    - name: "Remove rustdesk-hbbs service file"
      ansible.builtin.file:
        path: "/lib/systemd/system/rustdesk-hbbs.service"
        state: absent
      ignore_errors: true

    - name: "Reload systemd to apply changes"
      ansible.builtin.systemd:
        daemon_reload: true
      ignore_errors: true

    - name: "Remove hbbr binary"
      ansible.builtin.file:
        path: "{{ rustdesk__hbbr_executable_path }}"
        state: absent
      ignore_errors: true

    - name: "Remove hbbs binary"
      ansible.builtin.file:
        path: "{{ rustdesk__hbbs_executable_path }}"
        state: absent
      ignore_errors: true

    - name: "Remove rustdesk-utils binary"
      ansible.builtin.file:
        path: "{{ rustdesk__rustdesk_utils_executable_path }}"
        state: absent
      ignore_errors: true

    - name: "Remove RustDesk configuration directory"
      ansible.builtin.file:
        path: "{{ rustdesk__home }}"
        state: absent

    - name: "Remove RustDesk user"
      ansible.builtin.user:
        name: "{{ rustdesk__user }}"
        state: absent
      ignore_errors: true

    - name: "Remove RustDesk group"
      ansible.builtin.group:
        name: "{{ rustdesk__user }}"
        state: absent
      ignore_errors: true