EC2 provision
It took me a couple of hours to compile workable provision of EC2 using ansible. I found some bits and pieces none of which work from scratch in my MacOS environment. So I documented for myself all steps I had to take.
Assuming AWS account is open and in good shape...:
python3 -m venv ansi_env source ./bin/activate
pip install boto pip install ansible
name: asw_deployer policy: PowerUser
name: asw_ansible group: asw_deployer
Credetials_file in ~/.aws
[default] aws_access_key_id=xxx aws_secret_access_key=xxx [asw_ansible] aws_access_key_id=xxx aws_secret_access_key=xxx
Setting profile env var to be used by ansible/boto
export AWS_PROFILE=asw_ansible
Via console make new key_pair. Get *.pem file from AWS and place it in ~/.ssh It will be used when Ansible talk with new EC2. Add this key to ssh-agent to forward it( read docs if you need https://developer.github.com/v3/guides/using-ssh-agent-forwarding/)
ssh-add ~/.ssh/my_new_key.pem
The ansible_python_interpreter addition should point ansible to use boto from virtual env installation. Otherwise it will be looking on machine level installation..
[local] localhost ansible_python_interpreter=/Users/thats_me/projects/dev_ops/ansi_env/bin/python [webserver]
ansible-playbook -i ./hosts ec2_test.yml
Most of the steps above were adapted from here: https://www.agix.com.au/build-an-ec2-using-ansible-step-by-step/
When it's all set and done on the 7th day you may test success of creation:
ansible all -i hosts -u ec2-user -m ping