IBM Z DACH

IBM Z DACH

IBM Z DACH

User group for all IBM Z customers in Germany, Austria & Switzerland (DACH)

 View Only

IBM Terraform 101

By Dimitri Fankhauser posted 20 hours ago

  

English version below:

Terraform 101 

Vor einigen Wochen erhielt IBM Terraform Self-Managed for Z and LinuxONE den Status General Availability (GA). Da stellt man sich Fragen wie:

Was ist Terraform? Wieso sollte ich mich für Terraform interessieren? Was für Features hat Terraform auf IBM Z und LinuxONE? Im folgenden Beitrag werden die wichtigsten Fragen geklärt und eine Einführung in IBM Terraform gegeben.

 

Was ist Terraform und was kann ich damit machen?

Terraform ist ein IaC (= Infrastructure as Code) Werkzeug, das von HashiCorp entwickelt wurde. Die Idee von IaC ist simpel: Code schreiben und damit Infrastruktur provisionieren, verwalten und automatisieren. Das bringt einen klaren Vorteil mit sich:  Infrastruktur kann mit Standard-Tools wie Git versioniert werden. Es lassen sich entsprechend Module bauen, die versioniert deployt und gemanaged werden können. Damit lassen sich sehr simpel Basis-Konfigurationen erstellen, die man als Templates verwendet und bei Bedarf applikationsspezifisch modifiziert.

 

Wie funktioniert Terraform?

Terraform ist vendor-agnostisch und basiert auf dem Prinzip von Providern. Provider sind Abstraktionen von APIs und erlauben es einem einen Cloud Service Provider oder einen Service via Terraform zu steuern. Oder anders gesagt: mit Terraform kann man Virtuelle Maschinen, Container Registries und vieles mehr managen. Auf der Terraform Registry werden 422 Official sowie Partner Provider gelistet. Dazu kommen Tausende von Community Provider.

 

 

Wie entwickle ich mit Terraform?

Die Schritte, die man tätigt sind vergleichsweise simpel, denn es sind im Normalfall nur fünf:

  1. Code schreiben: was möchte ich für Infrastruktur haben?
  2. "terraform init": mit diesem Kommando weise ich Terraform an, die nötigen Provider herunterzuladen, damit ich bspw. mit IBM Cloud kommunizieren kann
  3. "terraform plan": durch dieses Kommando erstellt Terraform einen Ausführungsplan, um die Ressourcen zu erstellen. In diesem Schritt erhalte ich automatisch Feedback darüber, wie sich meine Infrastruktur verändern wird, wenn ich mein Skript starte. 
  4. "terraform apply": Die obige Konfiguration wird ausgeführt und die Ressourcen werden provisioniert
  5. "terraform destroy": dadurch werden die obigen Ressourcen wieder deprovisioniert

 

Inwiefern unterscheidet sich Terraform von Ansible?

Ansible und Terraform werden oft und gerne miteinander besprochen, denn die Tools haben viel gemeinsam. Mit beiden kann man Infrastruktur erstellen, managen und automatisieren. Grundsätzlich kann man auch beide verwenden, um auf der erstellten Infrastruktur Webserver oder andere Software zu installieren. Die Tools haben jedoch stark unterschiedliche Schwerpunkte.

Terraform wird deklarativ in HCL ("HashiCorp Configuration Language") geschrieben, wohingegen Ansible in YAML ("Yet Another Markup Language") in einem hybriden deklarativ/imperativen Programmierstil programmiert wird. Terraform merkt sich die Zustände der Infrastruktur, die es erzeugt und speichert diese in sogenannte State-Files ab. Ansible hingegen tut das nicht und basiert stark auf idempotenten Operationen, also: ein Ansible-Playbook kann man X-Fach aufrufen, ohne dass sich das Resultat ändert.

 

Terraform lässt sich gut mit Ansible kombinieren. Bei so einem Ansatz verwendet man meistens Terraform, um den Lebenszyklus der Umgebungen zu managen und Ansible für das Konfigurationsmanagement. Dieser Workflow wird durch den offiziellen Terraform Provider für die Ansible Automation Plattform weiterhin unterstützt.

 

Was findet sich im Release von IBM Terraform Self-Managed for Z and LinuxONE vom 17.6.?

  • Terraform-basierte Automatisierung von KVM und z/VM environments auf IBM Z and LinuxONE. Dies funktioniert über das IBM Cloud Infrastructure Center, also die OpenStack-kompatible Plattform für IBM Z und LinuxONE. Hier findet ihr die passende Dokumentation.
  • Terraform-basierte Automatisierung von z/OS Virtual Development und Test environments auf IBM Z und LinuxONE. Für diesen Use-Case gibt es bereits schon Beispiele auf Github

 

 

Summary

Zusammenfassend lässt sich sagen, dass man via IBM Terraform den gesamten Infrastruktur Lebenszyklus standardisieren und automatisieren kann. Dadurch kann man effizienter deployen und lässt weniger human errors zu. Zudem lässt sich IBM Terraform sehr gut mit bestehenden Tools wie Github Actions, Ansible oder Vault kombinieren, da Terraform durch eine Fülle von Providern unterstützt wird.

 

 

Zum Schluss ein paar spannende Links...

 

Unter diesem Link findet ihr alles zum IBM Cloud Terraform Provider

 

Auf dieser Seite findet ihr alles zum Release von IBM Terraform Self-Managed for Z and LinuxONE

 

 

English Version:
 

Terraform 101

A few weeks ago, IBM Terraform Self-Managed for Z and LinuxONE reached General Availability (GA). This raises questions like:

What is Terraform? Why should I care about Terraform? What features does Terraform offer on IBM Z and LinuxONE?

This article answers the most important questions and provides an introduction to IBM Terraform.

 

What is Terraform and what can I do with it?

Terraform is an Infrastructure as Code (IaC) tool initially developed by HashiCorp. The idea behind IaC is simple: write code to provision, manage, and automate infrastructure.

This brings a clear advantage: infrastructure can be versioned using standard tools like Git. You can build modules that are versioned, deployed, and managed accordingly. It also makes it easy to create base configurations that can be used as templates for deployments.

 

How does Terraform work?

Terraform is vendor-agnostic and works based on the concept of providers. Providers are abstractions of APIs and allow you to control a cloud service provider or service via Terraform. In other words: with Terraform, you can manage virtual machines, container registries, and so much more,

As of the writing of this blog, the Terraform Registry lists 422 official and partner providers, plus thousands of community providers.

 

How do I develop with Terraform?

The steps are relatively simple—usually just four:

  1. Write code: What infrastructure do I want?
  2. "terraform init": This command tells Terraform to download the necessary providers so it can communicate with your cloud service provider.
  3. "terraform plan": This command creates an execution plan to build the resources. It gives you feedback on how your infrastructure will change when you run your script.
  4. "terraform apply": Executes the configuration and provisions the resources.
  5. "terraform destroy": Deprovisions the resources.

 

How is Terraform different from Ansible?

Terraform and Ansible are often discussed together because they share many similarities. Both can be used to create, manage, and automate infrastructure.

You can also use both to install web servers or other software on the infrastructure. However, the tools have different focuses.

  • Terraform is written declaratively in HCL ("HashiCorp Configuration Language").
  • Ansible is written in YAML ("Yet another Markup Language") using a hybrid declarative/imperative style.

 

Terraform tracks the state of the infrastructure it creates and stores it in state files.

Ansible does not do this and relies heavily on idempotent operations—you can run an Ansible playbook multiple times without changing the result.

Terraform and Ansible work well together. A common approach is to use Terraform to manage the lifecycle of environments and Ansible for configuration management.

This workflow is supported by the official Terraform provider for the Ansible Automation Platform.

 

What’s included in the IBM Terraform Self-Managed for Z and LinuxONE release from June 17?

  • Terraform-based automation of KVM and z/VM environments on IBM Z and LinuxONE.
    This works via the
    IBM Cloud Infrastructure Center, the OpenStack-compatible platform for IBM Z and LinuxONE. Here’s the documentation.
  • Terraform-based automation of z/OS virtual development and test environments on IBM Z and LinuxONE.
    There are already examples available on Github

 

Summary

In summary, IBM Terraform allows you to standardize and automate the entire lifecycle of your infrastructure. Thereby reducing human error and improving outcomes.

IBM Terraform also integrates well with existing tools like GitHub Actions, Ansible, or Vault, thanks to its wide range of supported providers.

 

A few useful links...

0 comments
25 views

Permalink