In my previous blog post on using Terraform and Ansible to deploy a simple ‘dummy’ application, I showed you how to use Terraform to build a simple two-tier application infrastructure (Web/App + DB). This blog shows how to use Ansible to configure the application on the deployed infrastructure.
Ansible
For anyone unfamiliar with Ansible, I think this quote from the Ansible site covers what it is and what it does. For more information on Ansible please visit their site:
App deployment, configuration management and orchestration – all from one system. Ansible is powerful automation that you can learn quickly.
https://www.ansible.com/
Terraform Ansible Provider Plugin
As shown in the previous blog post first we will need the Terraform Ansible Provider Plugin to be able to define Ansible inventory information from within Terraform. This allows us to define groups (i.e. security for
This Ansible Provider Plugin can be found here and needs to be installed in the plugins directory. Which in my case (Ubuntu 18.04) has to be located in ~/.terraform.d/plugins (so in the users
After deploying your application infrastructure with Terraform the Ansible Inventory information will now be stored in the Terraform state-file (terraform.tfstate) which we can then use in Ansible by using a Ansible dynamic inventory script made for reading directly from

Terraform Dynamic Inventory Script
The Terraform Dynamic Inventory Script can now be used to retrieve the information from the


This information can now be used in
As you see above we put the database servers in the
Now we are ready to run our Ansible-playbook and further configure our application and thus putting it all together. I’ve
As mentioned in the previous
terraform destroy -var environment=DEV -var application=APP01 -auto-approve
Demo
Have a look at the full demo which shows what the execution of the deployment script looks like and the resulting infrastructure on AWS.
End of part 2 – Please stay tuned!
At a later stage, I will publish the full source code for you to be able to deploy the same kind of ‘dummy’ application. Currently, the example is just deploying a dummy application because I didn’t have the time yet to also set-up and deploy the configuration files for Apache2, MySQL and PHP to build a demo-application, but this will definitely happen in the future.
So please stay tuned for part 3 of this blogpost-series which will talk about how the application deployment developed from this stage on. If you have any specific questions at the moment about the set-up please feel to contact me.
Kelly Technologies
says:Inspirational content, have achieved a good knowledge from the above content on AWS Training useful for all the aspirants off AWS Training.