DevOps101?—?First Steps on Terraform: Terraform + OpenStack + Ansible

In DevOps101?—?Infrastructure as Code With Vagrant (LAMP Stack), I’ve introduced the Agile DevOps movement. It aims to automate work and allow you to launch faster.

If you are planning to start a business or side-project, something that you have to take into account is DevOps. Why should you care? As your business needs grow, you will have different infrastructure needs. Thus, if you build everything in the right way since the beginning, the cost of changing and upgrading will be lower. Without take any longer, let’s introduce:

Terraform aims to provide a workflow to manage infrastructures. It allows you to define infrastructures, allowing for a minimal cost to change and deploy changes.

This scheme synthesizes how Terraform works:

Terraform relies on .tf files, that define the infrastructure(terraform-instances). Terraform knows what is deployed through the state file. This state is stored by default in a local file named “terraform.tfstate”. It can also be stored remotely, which works better in a team environment. Terraform allows for several providers, normally initialized in a file called terraform-provider.tf. If you want to check in more detail how it works, check this introduction video, by Terraform.

Requirements

The code for this experiment is on Github. Fork the repository and after that clone it.

I strongly recommend you to use Vagrant. If you don’t know what Vagrant is or how it works, this article is suited for you (it even explains step by step how to configure the tool and their dependencies).

Before we start…

Step 1: Know your resources.

If you open the support files, you will see several filetypes: .tf, .yml, .cfg, .sh and a Vagrant file.

We can see 3 logical groups: files associated with Vagrant, Ansible, and Terraform. Vagrant provides you a virtual machine with the software required to run Terraform. Or, if you don’t want to use a virtual machine, you can install Terraform on your host machine.

Ansible is an open-source tool that aims to ease provisioning. Ansible will connect to the deployed instances by Terraform. After that, it will install the software required.

Finally, Terraform will be responsible for deploying the infrastructure.

Step 2: Initialize the virtual machine.

On the same directory that you have your support files, run vagrant up and wait for the machine to boot. Note that Vagrants synchronizes the current folder with terraform-experiment.

Now we are ready for the next step.

Step 3: Understand the Terraform support files.

Study terraform-provider.tf:

Created with carbon.sh (check it out)

As you can see, there are several variable declarations on this file. Some variables that are going to be passed to our provider.

Terraform’s providers are initialized in a different way, as they have different APIs. In other words, you need different variables set for each provider you are using. The variables you need for OpenStack are listed here. For this experiment, I’m going to use a private cloud from my university, based on OpenStack. You can use, for example, SUSE OpenStack Cloud, OpenTelekomCloud or any of this OpenStack-based private clouds. You can install OpenStack locally, and operate from there (the cheapest solution).

Facebook Comments

More Stuff

6 Cybersecurity Tools You’ll Need to Know About in 2019 It doesn’t take such a deep dive into 2018’s most important tech trends to understand how vital cybersecurity will be in the coming year. With the ide...
What you should know before working in Cybersecurity in the Milita... Photo by rawpixel on UnsplashHeard you are working in the weapon industry now ? How is sleeping at night going for you?This sentence was address...
Slack’n Go: Batch Presence Aware Bot We shall create a Slack Bot in Go which aware of Batch Presence change event. Essentially we are going to build and run the example given here: https:...
10 Free Courses to Learn Docker for Programmers and DevOps Enginee... “stack of cargo trailer” by Guillaume Bolduc on Unsplash As the software development is moving towards automation, a good knowledge and experienc...
Spread the love

Posted by News Monkey