https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
$ pip install ansible
$ pip install boto
$ pip install boto3
$ git clone https://github.com/ernesto-santos/fashion-cloud.git
$ cd ./fashion-cloud
$ cat set_credentials.sh
export AWS_ACCESS_KEY_ID='<<the_provided_access_key>>'
export AWS_SECRET_ACCESS_KEY='<<the_provided_secret_access>>'
export EC2_INI_PATH=./aws-invent/ec2.ini
$ . ./set_credentials.sh
$ ssh-add ./key-pair/fashion-cloud.pem
$ # if you would like to check the key..
$ ssh-add -l
Run the script to create the components:
$ ansible-playbook -i ./aws-invent/ec2.py ./fashion-cloud-playback_create.yml
$ ansible-playbook -i ./aws-invent/ec2.py ./fashion-cloud-playback_show_instances.yml
$ ssh ubuntu@<<instance_name_or_ip>> -i ./key-pair/fashion-cloud.pem
$ ansible-playbook -i ./aws-invent/ec2.py ./fashion-cloud-playback_show_lb.yml
Edit the script "fashion-cloud-playback_update_webservers.yml".
Then execute it to update the instances.
$ ansible-playbook -i ./aws-invent/ec2.py ./fashion-cloud-playback_update_webservers.yml
This script will remove all the created components.
OBS: Maybe you will need to execute the script twice, intending to remove the "security group". This is because it is dependency for the instances, and we need to remove/terminate the instances before we can remove the "security group".
$ ansible-playbook -i ./aws-invent/ec2.py ./fashion-cloud-playback_cleanup.yml
I hope you enjoy the lab / challenge.
Please, let me know if something does not work properly.
Best,
Ernesto