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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.