Running the deployment and tear-down playbooks

If you remember, earlier in our group_vars definition, we had a key variable (ssh_key_name: swarm_key) that at this point becomes relatively important as without a working key we can neither deploy nor start our VM, so let's do that now. We will use awscli and jq--a JSON parsing tool that will reduce the amount of work we do, but it is possible to do without it as well through the GUI console:

$ # Create the key with AWS API and save the private key to ~/.ssh directory$ aws ec2 create-key-pair --region us-west-1 \                          --key-name swarm_key | jq -r '.KeyMaterial' > ~/.ssh/ec2_swarm_key$ # Check that its not empty by checking the header$ head -1 ~/.ssh/ec2_swarm_key -----BEGIN RSA PRIVATE KEY-----

Get Deployment with Docker now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.