Trainer tools to prepare VMs for Docker workshops
There are several options for using these tools:
Clone the repo
$ git clone https://github.com/soulshake/prepare-vms.git $ cd prepare-vms $ docker-compose build $ mkdir $HOME/bin && ln -s `pwd`/trainer $HOME/bin/trainer
Via the image
$ docker pull soulshake/prepare-vms
This repo can be added as a submodule in the repo of the Docker workshop:
$ git submodule add https://github.com/soulshake/prepare-vms.git
Export needed envvars
Required environment variables:
If you have more than one workshop:
$ cp settings.yaml settings/YOUR_WORKSHOP_NAME-settings.yaml $ ln -s settings/YOUR_WORKSHOP_NAME-settings.yaml `pwd`/settings.yaml
settings.yaml as needed. This is the file that will be used to generate cards.
Summary of steps to launch a batch of instances for a workshop:
- Export the environment variables needed by the AWS CLI (see Requirements below)
trainer start NUMBER_OF_VMSto create AWS instances
trainer deploy TAGto run
trainer pull-images TAGto pre-pull a bunch of Docker images
trainer test TAG
trainer cards TAGto generate a PDF and an HTML file you can print
trainer script can be executed directly.
It will check for the necessary environment variables. Then, if all its dependencies are installed
locally, it will execute
trainer-cli. If not, it will look for a local Docker image
soulshake/trainer-tools. If found, it will run in a container. If not found,
the user will be prompted to either install the missing dependencies or download
the Docker image.
Start some VMs
$ trainer start 10
A few things will happen:
Sync of SSH keys
start command is run, your local RSA SSH public key will be added to your AWS EC2 keychain.
To see which local key will be uploaded, run
ssh-add -l | grep RSA.
Instance + tag creation
10 VMs will be started, with an automatically generated tag (timestamp + your username).
Your SSH key will be added to the
authorized_keys of the ubuntu user.
Creation of ./$TAG/ directory and contents
Following the creation of the VMs, a text file will be created containing a list of their IPs.
This ips.txt file will be created in the $TAG/ directory and a symlink will be placed in the working directory of the script.
If you create new VMs, the symlinked file will be overwritten.
Instances can be deployed manually using the
$ trainer deploy TAG
postprep.rc file will be copied via parallel-ssh to all of the VMs and executed.
$ trainer pull-images TAG
$ trainer cards TAG
$ trainer list
$ trainer list TAG
This will print a human-friendly list containing some information about each instance.
Stop and destroy VMs
$ trainer stop TAG
- Don't write to bash history in system() in postprep
- compose, etc version inconsistent (int vs str)