Ansible playbook will initially creates an image with apache and tomcat 8. Terraform then uses this image to launch ELB and ASG in three AZ in AWS eu-east-1 region. The workflow is controlled and orchestrated through Ansible
Ansible and Terraform installed on the local machine and added to default path. export PATH=$PATH:/path/to/installtion.
boto3 boto
Before running the playbook, you need to to make changes to a few of the configuration files.
Edit ansible.cfg
to specify the location of your AWS private key file. Ensure key pair is created in the region.
KeyPair used in the demo is aws-demo.
Change the permission of the keypair : chmod 400 aws-demo.pem
Edit group_vars/all
to set the following values:
- aws_access_key: specify AWS Access Key
- aws_secret_key: specify AWS Secret Key
Edit inventory/hosts
to specify a custom Python path
Edit Terraform/terrafor.tfvars
to set the following values:
access_key = specify AWS Access Key secret_key = specify AWS Secret Key
To run the playbook, you only need to use a single command
$ ansible-playbook -i inventory/hosts ansible-terraform.yml