From ea031a62313dc9486e85b0e6750acdc17e808741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Sat, 24 Apr 2021 17:25:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=82=EF=B8=8F=20Remove=20listall=20command?= =?UTF-8?q?;=20rename=20list=20into=20inventory;=20update=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prepare-vms/README.md | 55 ++++++++++++++++--------------------- prepare-vms/lib/cli.sh | 2 +- prepare-vms/lib/commands.sh | 19 ++----------- 3 files changed, 26 insertions(+), 50 deletions(-) diff --git a/prepare-vms/README.md b/prepare-vms/README.md index 4dbaff56..6b6d2e68 100644 --- a/prepare-vms/README.md +++ b/prepare-vms/README.md @@ -4,7 +4,11 @@ These tools can help you to create VMs on: - Azure - EC2 +- Hetzner +- Linode - OpenStack +- OVHcloud +- Scaleway ## Prerequisites @@ -13,7 +17,8 @@ These tools can help you to create VMs on: - [Parallel SSH](https://code.google.com/archive/p/parallel-ssh/) (on a Mac: `brew install pssh`) Depending on the infrastructure that you want to use, you also need to install -the Azure CLI, the AWS CLI, or terraform (for OpenStack deployment). +the CLI that is specific to that cloud. For OpenStack deployments, you will +need Terraform. And if you want to generate printable cards: @@ -90,6 +95,9 @@ You're all set! ## `./workshopctl` Usage +If you run `./workshopctl` without arguments, it will show a list of +available commands, looking like this: + ``` workshopctl - the orchestration workshop swiss army knife Commands: @@ -98,32 +106,7 @@ cards Generate ready-to-print cards for a group of VMs deploy Install Docker on a bunch of running VMs disableaddrchecks Disable source/destination IP address checks disabledocker Stop Docker Engine and don't restart it automatically -helmprom Install Helm and Prometheus -help Show available commands -ids (FIXME) List the instance IDs belonging to a given tag or token -kubebins Install Kubernetes and CNI binaries but don't start anything -kubereset Wipe out Kubernetes configuration on all nodes -kube Setup kubernetes clusters with kubeadm (must be run AFTER deploy) -kubetest Check that all nodes are reporting as Ready -listall List VMs running on all configured infrastructures -list List available groups for a given infrastructure -netfix Disable GRO and run a pinger job on the VMs -opensg Open the default security group to ALL ingress traffic -ping Ping VMs in a given tag, to check that they have network access -pssh Run an arbitrary command on all nodes -pull_images Pre-pull a bunch of Docker images -quotas Check our infrastructure quotas (max instances) -remap_nodeports Remap NodePort range to 10000-10999 -retag (FIXME) Apply a new tag to a group of VMs -ssh Open an SSH session to the first node of a tag -start Start a group of VMs -stop Stop (terminate, shutdown, kill, remove, destroy...) instances -tags List groups of VMs known locally -test Run tests (pre-flight checks) on a group of VMs -weavetest Check that weave seems properly setup -webssh Install a WEB SSH server on the machines (port 1080) -wrap Run this program in a container -www Run a web server to access card HTML and PDF +... ``` ### Summary of What `./workshopctl` Does For You @@ -138,7 +121,8 @@ www Run a web server to access card HTML and PDF ### Example Steps to Launch a group of AWS Instances for a Workshop -- Run `./workshopctl start --infra infra/aws-us-east-2 --settings/myworkshop.yaml --count 60` to create 60 EC2 instances +- Run `./workshopctl start --infra infra/aws-us-east-2 --settings/myworkshop.yaml --students 50` to create 50 clusters + - The number of instances will be `students × clustersize` - Your local SSH key will be synced to instances under `ubuntu` user - AWS instances will be created and tagged based on date, and IP's stored in `prepare-vms/tags/` - Run `./workshopctl deploy TAG` to run `lib/postprep.py` via parallel-ssh @@ -248,12 +232,19 @@ If you don't have `wkhtmltopdf` installed, you will get a warning that it is a m #### List tags - $ ./workshopctl list infra/some-infra-file - - $ ./workshopctl listall - $ ./workshopctl tags + $ ./workshopctl inventory infra/some-infra-file + + $ ./workshopctl inventory + +Note: the `tags` command will show only the VMs that you have provisioned +and deployed on the current machine (i.e. listed in the `tags` subdirectory). +The `inventory` command will try to list all existing VMs (including the +ones not listed in the `tags` directory, and including VMs provisioned +through other mechanisms). It is not supported across all platforms, +however. + #### Stop and destroy VMs $ ./workshopctl stop TAG diff --git a/prepare-vms/lib/cli.sh b/prepare-vms/lib/cli.sh index acb65fb1..0290e2ea 100644 --- a/prepare-vms/lib/cli.sh +++ b/prepare-vms/lib/cli.sh @@ -66,7 +66,7 @@ need_infra() { need_tag() { if [ -z "$TAG" ]; then - die "Please specify a tag or token. To see available tags and tokens, run: $0 list" + die "Please specify a tag. To see available tags, run: $0 tags" fi if [ ! -d "tags/$TAG" ]; then die "Tag $TAG not found (directory tags/$TAG does not exist)." diff --git a/prepare-vms/lib/commands.sh b/prepare-vms/lib/commands.sh index 636cfdf2..b3c39b83 100644 --- a/prepare-vms/lib/commands.sh +++ b/prepare-vms/lib/commands.sh @@ -419,8 +419,8 @@ _cmd_ips() { done < tags/$TAG/ips.txt } -_cmd list "List all VMs on a given infrastructure (or all infras if no arg given)" -_cmd_list() { +_cmd inventory "List all VMs on a given infrastructure (or all infras if no arg given)" +_cmd_inventory() { case "$1" in "") for INFRA in infra/*; do @@ -437,21 +437,6 @@ _cmd_list() { esac } -_cmd listall "List VMs running on all configured infrastructures" -_cmd_listall() { - for infra in infra/*; do - case $infra in - infra/example.*) - ;; - *) - info "Listing infrastructure $infra:" - need_infra $infra - infra_list - ;; - esac - done -} - _cmd maketag "Generate a quasi-unique tag for a group of instances" _cmd_maketag() { if [ -z $USER ]; then