--- # Run with tailscale_remove=true (and tailscale_remove_data=true to purge), tag: remove. main.yml # installs and configures Tailscale again afterwards. - name: Log Tailscale out of the tailnet become: true ansible.builtin.command: tailscale logout register: __tailscale_logout changed_when: __tailscale_logout.rc == 0 # Best effort: already logged out, tailscaled down or binary missing must not block the removal. A # failed logout leaves a stale device in the tailnet admin console. failed_when: false tags: [tailscale, remove] - name: Stop and disable tailscaled service become: true ansible.builtin.systemd: name: tailscaled state: stopped enabled: false register: __tailscale_stop # A host without the package has no unit; there is nothing to stop then. failed_when: - __tailscale_stop is failed - "'Could not find the requested service' not in __tailscale_stop.msg | default('')" tags: [tailscale, remove] - name: Remove Tailscale package become: true ansible.builtin.apt: name: "{{ tailscale_package }}" state: absent purge: "{{ tailscale_remove_data | bool }}" tags: [tailscale, remove] - name: Remove Tailscale APT source list become: true ansible.builtin.file: path: "{{ tailscale_apt_list_path }}" state: absent tags: [tailscale, remove] - name: Remove Tailscale APT keyring become: true ansible.builtin.file: path: "{{ tailscale_keyring_path }}" state: absent tags: [tailscale, remove] - name: Remove Tailscale state directory become: true ansible.builtin.file: path: "{{ tailscale_state_dir }}" state: absent when: tailscale_remove_data | bool tags: [tailscale, remove]