Created
February 12, 2018 15:00
-
-
Save superseb/8bc5e51a1019b9139b365fd9bc035583 to your computer and use it in GitHub Desktop.
Delete disconnected hosts in Rancher environment
This file contains 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
#!/bin/bash | |
RANCHER_URL=http://rancher_server:8080 | |
ENV=1a7 | |
for host in `curl -s http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/ | jq -r '.data[] | select(.state == "disconnected") | .id'`; do echo Deactivating $host; curl -X POST -d '{}' http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/$host/?action=deactivate; echo Deleting $host; curl -X DELETE -H 'Accept: application/json' http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/$host; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment