Setting up Ansible
We need to set up and install Ansible in the control node, but before we do that, we will have to spin three servers to start the activity – an Ansible control node and two managed nodes.
Setting up inventory
The idea is to set up a two-tier architecture with Apache and MySQL. So let's use Terraform to spin up the three servers.
Let's first cd
into the directory where the Terraform templates are located, and then edit the terraform.tfvars
file to fill in the required details. (Please refer to Chapter 6, Infrastructure as Code (IaC) with Terraform, for more details about how to get the attributes):
$ cd ~/modern-devops/ch7/setup-ansible-terraform $ vim terraform.tfvars
Then, use the following commands to spin up the servers using Terraform:
$ terraform init $ terraform plan -out ansible.tfplan $ terraform apply ansible.tfplan
Once we have the terraform apply
command completed successfully, we will see three servers – ansible...