Working with the Ubuntu 18.04 default image as of 2019 it’s very easy to spin up an instance and deploy/manage stuff on it with Ansible.
I will list some common snippets I use, to quickly have a running EC2 instance with python3, virtualenv, flask and more.
Contents of .hosts file:
Contents of deploy.yml file:
As noted, the python2, mv and vim stuff it optional, this is just my personal preference on any given linux host.
Now start an EC2 instance and use the .pem file to get access. Copy your own id_rsa.pub to the ubuntu user at the EC2 instance, so you can login without a password and you are ready to use Ansible, including the possibility to become root when needed.
Add the IP or host name to your .hosts file and run.
Create a virtualenv and:
Test connection with the host. If needed, configure the ssh agent.
Rerun the playbook with verbosity.
More to come in other posts.
Quick Links
Legal Stuff