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

Uninstall and cleanup #9

Open
marosg42 opened this issue May 29, 2024 · 1 comment
Open

Uninstall and cleanup #9

marosg42 opened this issue May 29, 2024 · 1 comment

Comments

@marosg42
Copy link

In the case when MAAS will be installed and reinstalled, sometimes with anvil, sometimes with snap or deb there needs to be a way how to cleanup and have environment ready for any other installation, so no leftovers prevent clean install with any of the possible methods.

There are basically two scenarios which needs to be covered

  • when anvil installation worked as expected, is it enough to run juju destroy-model?
  • when something goes wrong during install and juju cannot be used

The second scenario will leave postgres snap installed on the machine, it would have mounted data for example

I ended up using combination of these commands

juju destroy-model admin/controller
sudo /usr/sbin/remove-juju-services
sudo umount /var/snap/charmed-postgresql/common
sudo umount /var/lib/snapd/snaps/charmed-postgresql_96.snap

for i in charmed-postgresql juju juju-db maas maas-anvil ; do sudo snap remove $i --purge ; done
rm -rf ~/.local/share/juju
sudo pkill haproxy

It would be great to have some script with smarts which would take care of both successful and failed installation.

@marosg42
Copy link
Author

marosg42 commented Jul 18, 2024

Here is my big hammer temporary solution which seems to do the work. It is not nice at all but you may find some inspiration there

# timeout is set because I saw cases where it did not finish in 30 minutes and it was not progressing
ssh 10.244.40.30 "timeout 900 juju destroy-controller --destroy-all-models --destroy-storage --no-prompt anvil-controller"
for i in 30 31 32 ; do ssh 10.244.40.$i "sudo /usr/sbin/remove-juju-services" ; done
for i in 30 31 32 ; do ssh 10.244.40.$i "rm -rf .local/share/juju/" ; done
for i in 30 31 32 ; do ssh 10.244.40.$i "sudo snap stop charmed-postgresql" ; done
for i in 30 31 32 ; do ssh 10.244.40.$i "sudo umount /var/snap/charmed-postgresql/common; sudo umount /var/lib/snapd/snaps/charmed-postgresql_*.snap" ; done
for i in 30 31 32 ; do ssh 10.244.40.$i "for i in charmed-pgbouncer charmed-postgresql juju juju-db maas-anvil ; do sudo snap remove --purge \$i; done; sudo snap unalias patronictl"; done
for i in 30 31 32 ; do ssh 10.244.40.$i "sudo rm -rf /var/lib/juju" ; done

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

No branches or pull requests

1 participant