Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Improve decomission process #430

Closed
wants to merge 6 commits into from
Closed

Conversation

McSim85
Copy link
Contributor

@McSim85 McSim85 commented Feb 14, 2024

Often, when I run the role with state: absent, the next role run with state: present will fail with different errors like described in the bug
#429

After talking to Tailscale support, that might happen if /var/lib/tailscale/ still contains the previous machine identity (auth key, id, etc).

We have to remove this folder during decommission.
Fortunately, Ubuntu package has that task inside the tailscale.postrm, (if the user rune apt purge tailscale):

$ cat /var/lib/dpkg/info/tailscale.postrm
#!/bin/sh
set -e
if [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi

if [ -x "/usr/bin/deb-systemd-helper" ]; then
    if [ "$1" = "remove" ]; then
		deb-systemd-helper mask 'tailscaled.service' >/dev/null || true
	fi

    if [ "$1" = "purge" ]; then
		deb-systemd-helper purge 'tailscaled.service' >/dev/null || true
		deb-systemd-helper unmask 'tailscaled.service' >/dev/null || true
		rm -rf /var/lib/tailscale
	fi
fi

So, this is the best way to handle tailscale state removal - purge: true, because this will always be aligned with the package maintainers config.

I am not sure about other distros, though.
Probably, we need a task like this in each distro subtree:

- name: Uninstall | Delete Tailscale Package State
  ansible.builtin.file:
    path: "/var/lib/tailscale"
    state: absent

@artis3n , please let me know how you prefer to handle this.

@@ -32,3 +32,6 @@ insecurely_log_authkey: false
# Whether to store hashed authkey in state
# Setting to false won't re-run 'tailscale up' on authkey change
auth_key_in_state: true
# Whether to purge state on uninstall
# Setting to true will clean up the state folder /var/lib/tailscale
tailscale_purge_state: false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to handle this differently, let's exclude adding a variable in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create another PR.
Because current changes are actively in use :)

@McSim85
Copy link
Contributor Author

McSim85 commented Feb 17, 2024

I will create another PR.
Because current changes are actively in use :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants