- AWS account.
- AWS access key and AWS secret key.
- Ec2.py file and ec2.ini file if you want to go for automated process. click here for downloading ec2.py and ec2.ini file.
We can configure webserver on AWS using two logic. One is we can launch the instance manually on AWS take its public IP address and put it in the inventory file of ansible and after that run the playbook for webserver configuration. Another way is we do all the thing with the help of ansible, i.e., from launching ec2 instance till configuring web server all will be taken care by ansible. We only need to write the playbook once.
I have done everything using ansible. One playbook will be used for launching the instance whereas other will be used for configuring webserver.
I have created to yml files named www.yml and d.yml. Below you will find attached picture of code snippet.
Inside the www.yml I have run d.yml with the help of shell module of ansible to achieve everything in single click.