Last active
May 12, 2021 19:09
-
-
Save nottrobin/4e2a94db24ac9daddcee6996ad4c1062 to your computer and use it in GitHub Desktop.
To clean out a Juju model so you can use it from scratch, without deleting and recreating it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clear out a model, for Juju 2 | |
# == | |
# Destroy all machines and remove applications | |
# -- | |
clean_model() { | |
model_name=${1} | |
juju status --model ${model_name} --format json | jq '.machines' | jq -r 'keys[]' | xargs -n 1 juju remove-machine --force # Force destroy all machines | |
juju status --model ${model_name} --format json | jq '.applications' | jq -r 'keys[]' | xargs -n 1 juju remove-application # Remove all applications | |
watch -c -n 10 juju status --model ${model_name} --color | |
} | |
# Other useful commands | |
# == | |
juju status --format json | jq '.machines' | jq -r 'keys[]' # Get all machines | |
juju status --format json | jq '.applications' | jq -r 'keys[]' # Get all applications | |
juju status --format short | awk '{print $2}' | sed -E 's/:$//' # Get all units | |
juju status --format short | awk '{print $2}' | sed -E 's/:$//' | xargs -n 1 juju resolved --no-retry # Resolve all problems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment