This repository contains the following:
- Terraform scripts to setup the overall infrastructure on AWS.
- Ansible playbook to set up individual apps.
-
Create a
credentials
file in theterraform
folder that has the same format as thecredentials.example
file. Add the access key id and secret key of the account you want to set up the infrastructure in to thecredentials
file. -
Run terraform from within the
terraform
folder:terraform init
,terraform plan
andterraform apply
.
-
Update the
ansible/hosts
file with the IP address or host name of the newly created EC2 instance using Terraform. -
Update the
hosts
property inansible/playbook.yml
to use the host you just added in the previous step. -
Ensure that you have an SSH key pair set up to access the EC2 instance. Update the script
run_playbook.sh
with your private key file name after the--key-file
property. -
Execute the script
run_playbook.sh
to run the playbook against the EC2 instance.
To run the playbook locally against a Vagrant box, update the ansible/playbook.yml
playbook to use the host default
and execute the following command:
$ ansible-playbook ansible/playbook.yml -i ansible/hosts
The default
host has all the necessary parameters to connect to the Vagrant box created using the Vagrantfile in this repository.
Note: you might have to update the path to the SSH key required to connect to the Vagrant box in the ansible/hosts
file.