Configurations needed on the control machine.
-
Install Ansible
-
Install boto3
sudo pip install boto boto3
For macOS, you need to
sudo pip install boto3 --ignore-installed six
If python or pip was not installed on the control machine:
sudo apt install python python-pip
-
Environment variables
Ansible ec2 module uses the following environment variables if
aws_access_key
andaws_secret_key
are not specified in the script.export AWS_ACCESS_KEY_ID=your_aws_access_key_id export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
./main.sh
- Regarding to step 9 - "Log the resource usage of the container every 10 seconds", it seems Ansible does not support real-time output according to this github issue. It was posted 4 years ago though, other later discussions on stackoverflow like this conform to that, so alternatively the loop could be done in a shell script and call the Ansible playbook every ten seconds. Please refer to main.sh for more details about this approach.