Table of Contents
What is Ansible Terraform
Ansible and Terraform are very common in the DevOps world. Ansible is used to manage a group of servers, while Terraform is used to manage an entire cloud infrastructure. Both can be implemented together to control your entire infrastructure in a single step. For example, you could execute an ansible command to configure a pair of servers, then step back and use Terraform to deploy a whole Hadoop cluster. This article will examine how the two tools can be used together to provide a more flexible solution.
Ansible is an extremely powerful open source tool available on CentOS, Fedora, Red Hat Enterprise Linux and Ubuntu. It automates software configuration, deployment and management of systems over SSH or PowerShell by pushing commands to the managed nodes. It can set up software packages, manage file permissions, copy and backup data, and deploy web applications.

How does it work
Ansible is a configuration management tool. It works by connecting to the target hosts and running the tasks defined in playbooks. Ansible will read the environment variables (e.g., the type of server and how it should be configured) that are relevant to the task you are running, and use them to configure the desired behavior. Ansible then returns this configuration to your system, where it can be stored as a file or used in an operating system shell script without a restart. Terraform is an extremely powerful tool for managing infrastructure and creating/managing infrastructure easily and flexibly. Terraform is a powerful tool that works by reading configuration files (terraform.tf) and creating an execution plan. This execution plan is then passed to the Terraform CLI tool and it will configure infrastructure on the target nodes by executing the plan.
##How does it work? [ANSIBLE]**1.** First, Ansible connects to the target host over SSH and runs ad-hoc commands or scripts, which can be run from a local system, or from a remote system over SSH. Ansible then gathers information about the system and stores it in memory. Finally, Ansible runs the Playbook, reads variables from inventory and uses those variables where necessary to complete tasks in the Playbook. Or Ansible can run ad-hoc commands on the target system instead of a Playbook.

The benefits of using Ansible Terraform
Ansible and Terraform can be used together to push an entire infrastructure in a single command, greatly reducing the time it takes to configure a whole new infrastructure. Ansible and Terraform have been very common in DevOps environments and are used by IT professionals every day. Terraform is also great for developers. It is easy to manage your own infrastructure on GitHub, so you can use Terraform to manage your own infrastructure.
Common problems:
Monotonous and repetitive. Ansible is wonderful for repetitive tasks that need to be done in a single step, and for projects with a small team. You can design the infrastructure you need to create a production setup, configure it all at once, and then repeat this process whenever your infrastructure changes. Terraform can be more difficult to set up because of its modularity. It is best to keep configuration files tidy and organized for ease of maintenance.

How to get started with Ansible Terraform
You can get started with Ansible and Terraform in a single command! For example, to push all the data from the gpio.org database into your local git repository and clone it locally: $ ansible-playbook -i localhost.yml setup.yml –tags=git –ask-sudo-pass -u git $ git clone ssh://[email protected]:22222/gpio.org
The first command pushes all the data from the gpio.org database into your local git repository; you can then clone it locally with the second command:
# run it as sudo if you don’t have a terraform role for user # or if you want terraform to have @git as a github eduroam account git clone ssh://[email protected]:22222/gpio.org
In order to setup the terraform repo, run:
$ ansible-playbook -i localhost.yml setup.yml –tags=git –ask-sudo-pass -u git $ git clone ssh://[email protected]:22222/gpio.org $ cd gpio.org $ git remote add upstream https://github.com/james-w/gpio.org.git $ git fetch upstream