Seite wählen

NETWAYS Blog

Terraform Training: Provisionierung von Infrastruktur in der Cloud

Mit dem Infrastructure-as-Code-Werkzeug (IaC) Terraform lässt sich Infrastruktur für Anwendungen in der Cloud automatisiert erstellen und verwalten. Das Tool abstrahiert die APIs unterschiedlicher Anbieter mit sogenannten Providern. So kann die Konfiguration Deiner Infrastruktur revisionssicher dokumentiert und von allen Teammitgliedern gemeinsam genutzt und bearbeitet werden.

Terraform nimmt Administrator*innen und Entwickler*innen viel Routinearbeit ab, erfordert aber eine gute Einarbeitung. Und hier kommen wir ins Spiel: In unserer Schulung lernst Du, wie Du mit Terraform Infrastrukturen sicher und nachvollziehbar erstellen, ändern und verbessern kannst.

Mit der aktuellen Version von Terraform und seiner Konfigurationssprache HCL (Hashicorp Configuration Language) in Version 0.12 hat sich das Vorgehen zur Automatisierung von Cloud-Infrastruktur weiterentwickelt.

Von HCL bis cloud-init

Unsere zweitägige Schulung beginnt mit einer Einführung in HCL. Anschließend zeigen wir Dir, wie Du Infrastruktur für AWS oder OpenStack wiederverwendbar und idempotent mit Terraform realisierst. Ebenfalls erfolgt eine Einführung in cloud-init, um weitere Software zu installieren und zu konfigurieren.

Folgende Linux-Kenntnisse sind Grundvoraussetzung zur Teilnahme: sicherer Umgang mit der Kommandozeile, ssh und vim bzw. einem alternativen Editor. Bringst Du mit? Na dann, willkommen zur Weiterbildung!

Aktuell haben wir folgende Termine im Angebot:

Unsere Trainer sind nicht nur im Bereich Schulungen tätig, sondern arbeiten regelmäßig in Software- und Kundenprojekten. Wir wissen, worauf es ankommt und teilen unser Wissen gerne – für Deinen Erfolg!

Erfahre hier mehr zur Terraform Schulung und melde Dich an!

stackconf online: stream, chat, network

stackconf is coming! We have crafted an inspiring agenda for you! Here are some highlights that you surely don’t wanna miss.

Hybrid cloud environments

Hybrid cloud environments were never easy and mostly just an idea. With Kubernetes though it is easy to deploy your infrastructure on premise and to a cloud provider.

This is where you learn more about hybrid cloud environments:

Containers

Increased portability makes containers so powerful. A big plus is that it can prevent a vendor lock-in. Applications running in containers can be deployed easily to multiple different operating systems and hardware platforms.

Learn more about containers in these talks:

Agile methods & continuous integration

Good IT is not possible with just the right tool. It is important that you have your communication and processes in shape. DevOps, agile, you name it always comes down to communication and transparency. Tear down silos to make your IT infrastructure and business as fast and efficient as possible.

Get to know agile methods and continuous integration practices in these talks:

And we have even more for you: Find the full schedule at stackconf.eu/schedule.

This is how it works: stream, chat, network

All the recorded talks will be presented in a single track over the course of three days from June 16 – 18, 2020. You can easily attend and watch!

Just watching, or what? Of course not! stackconf is a highly interactive online event – if you want it to be! Chat with the experts. Spice up open discussions with your thoughts in the hallway channel and in various topic-related channels. Meet friends and fellow infrastructure experts in private chats. Plus, there might be one or another challenge or gaming opportunity.

Short: There is plenty of opportunity to learn and have fun!

Fruitful discussions and hardest questions

While you watch a talk in the stream the speaker will be present in a parallel live chat to answer your questions. Feel free to comment the presentation, add your thoughts to it and ask your hardest questions! We are looking forward to a fruitful and inspiring exchange of ideas.

During lunch break a moderated discussion will take place. Join in and contribute to it. There will be additional room for networking and informal get-together during the community evening at the second conference day – Wednesday, June 17, 2020. We’ll continue the topic-related discussions, and open the gaming arena, where you can compare your gaming skills.

Stay up to date

Get posted on the latest expert knowledge on open source infrastructure solutions! We look forward to seeing you online at stackconf.

stackconf online takes place June 16 – 18, 2020. More: stackconf.eu

Managing your Ansible Environment with Galaxy

Ansible is known for its simplicity, lightweight footprint and flexibility to configure nearly any device in your infrastructure. Therefore it’s used in large scale environments shared between teams or departments. This leads to even bigger Ansible environments which need to be tracked or managed in version control systems like Git.

Mostly environments grow with their usage over time, in this case it can happen that all roles are managed inside one big repository. Which will eventually lead to quite messy configuration and loss of knowledge if roles are tested or work the way they supposed to work.

Ansible provides a solution which is called Galaxy, it’s basically a command line tool which keeps your environment structured, lightweight and enforces your roles to be available in a specific version.

First of all you can use the tool to download and manage roles from the Ansible Galaxy which hosts many roles written by open-source enthusiasts. 🙂


# ansible-galaxy install geerlingguy.ntp -v
Using /Users/twening/ansible.cfg as config file
 - downloading role 'ntp', owned by geerlingguy
 - downloading role from https://github.com/geerlingguy/ansible-role-ntp/archive/1.6.4.tar.gz
 - extracting geerlingguy.ntp to /Users/twening/.ansible/roles/geerlingguy.ntp
 - geerlingguy.ntp (1.6.4) was installed successfully

# ansible-galaxy list
# /Users/twening/.ansible/roles
 - geerlingguy.apache, 3.1.0
 - geerlingguy.ntp, 1.6.4
 - geerlingguy.mysql, 2.9.5

Furthermore it can handle roles from your own Git based repository. Tags, branches and commit hashes can be used to ensure it’s installed in the right version.


ansible-galaxy install git+https://github.com/Icinga/ansible-icinga2.git,v0.2.0
 - extracting ansible-icinga2 to /Users/twening/.ansible/roles/ansible-icinga2
 - ansible-icinga2 (v0.2.0) was installed successfully

It’s pretty neat but how does this help us in large environments with hundreds of roles?

The galaxy command can read requirement files, which are passed with the „-r“ flag. This requirements.yml file can be a replacement for roles in the roles path and includes all managed roles of the environment.


# vim requirements.yml
- src: https://github.com/Icinga/ansible-icinga2.git
  version: v0.2.0
  name: icinga2

- src: geerlingguy.mysql
  version: 2.9.5
  name: mysql

Then run ansible-galaxy with the „–role-file“ parameter and let galaxy manage all your roles.


# ansible-galaxy install -r requirements.yml
 - icinga2 (v0.2.0) is already installed, skipping.
 - downloading role 'mysql', owned by geerlingguy
 - downloading role from https://github.com/geerlingguy/ansible-role-mysql/archive/2.9.5.tar.gz
 - extracting mysql to /Users/twening/.ansible/roles/mysql
 - mysql (2.9.5) was installed successfully

In case you work with Ansible AWX, you can easily replace all your roles with this file in the roles directory and AWX will download and manage your roles directory automatically.

A example project could look like this.


awx_project/
├── example_playbook.yml
├── group_vars
├── host_vars
├── hosts
└── roles
    └── requirements.yml

In summary, in large environments try to keep your code and configuration data separated, try to maintain your roles in their own repository to avoid conflicts at the main project.

Check out our Blog for more awesome posts and if you need help with Ansible send us a message or sign up for one of our trainings!

Thilo Wening
Thilo Wening
Manager Consulting

Thilo hat bei NETWAYS mit der Ausbildung zum Fachinformatiker, Schwerpunkt Systemadministration begonnen und unterstützt nun nach erfolgreich bestandener Prüfung tatkräftig die Kollegen im Consulting. In seiner Freizeit ist er athletisch in der Senkrechten unterwegs und stählt seine Muskeln beim Bouldern. Als richtiger Profi macht er das natürlich am liebsten in der Natur und geht nur noch in Ausnahmefällen in die Kletterhalle.

Ansible can talk to your favorite API

Ansible is a powerful opensource config management and deployment tool, which can manage nearly any situtation. In many „DevOp“ scenarios we come across multiple platforms, which we need to combine. Mostly applications provide an REST Api or web connectors to manage resources, jobs and deployments within the product.
Ansible provides various modules which can execute commands at specific APIs, such as the vmware-guest-module to create virtual machines or the jenkins-job-module to manage jobs over the Jenkins API.
In cases where no module is available, we can use the module „uri“.

The module takes several parameters, of which the „url“ is the only required one. For this example I picked an example online API „http://dummy.restapiexample.com/“.
To get a list of all employees we use the method GET on , the header Accept: application/json and register the content.


- name: Make requests to example api
  hosts: localhost
  connection: local
  tasks:
    - name: list employees
      uri:
        method: GET
        url: "http://dummy.restapiexample.com/api/v1/employees"
        return_content: yes
        headers:
          Accept: application/json
      register: response

    - debug:
        msg: "{{ response.content }}"

# Result
TASK [list employees] *************************************************************************
ok: [localhost]

TASK [debug] **********************************************************************************
ok: [localhost] => {
    "msg": [
        {
            "employee_age": "23",
            "employee_name": "test",
            "employee_salary": "46000",
            "id": "12008",
            "profile_image": ""
        }
    ]
}

Now we create a new user in our application, for this we talk to a different url and send a body with our user to create.
When the api accepts JSON I use a little trick to generate a valid json body out of yaml variables with the Ansible filter to_json

For this we create a variable with the same key value structure as the API expects it, in this case the structure looks like this {„name“:“test“,“salary“:“123″,“age“:“23″}.


- name: Make requests to example api
  hosts: localhost
  connection: local
  vars:
    data:
      chris:
        name: chris
        salary: 46000
        age: 27
      jessy:
        name: jessy
        salary: 70000
        age: 30
  tasks:
    - name: create employee
      uri:
        method: POST
        url: "http://dummy.restapiexample.com/api/v1/create"
        return_content: yes
        headers:
          Accept: application/json
        body_format: json
        body: "{{ item.value | to_json }}" //Render valid json from each dictionary in the variable data.
      with_dict: "{{ data }}"
      register: post_content

    - debug:
        msg: "{{ item.content }}"
      with_items: "{{ post_content.results }}"

# Result
ansible-playbook create_user.yaml

PLAY [Make requests to example api] ********************************************************************

TASK [Gathering Facts] *********************************************************************************
ok: [localhost]

TASK [create employee] *********************************************************************************
ok: [localhost] => (item={'value': {u'salary': 46000, u'age': 27, u'name': u'chris'}, 'key': u'chris'})
ok: [localhost] => (item={'value': {u'salary': 70000, u'age': 30, u'name': u'jessy'}, 'key': u'jessy'})

With this information given, you can now explore your own favorite API and hopefully reduce your daily tasks as simple Ansible playbooks.

Check out our Blog for more awesome posts and if you need help with Ansible send us a message!

Thilo Wening
Thilo Wening
Manager Consulting

Thilo hat bei NETWAYS mit der Ausbildung zum Fachinformatiker, Schwerpunkt Systemadministration begonnen und unterstützt nun nach erfolgreich bestandener Prüfung tatkräftig die Kollegen im Consulting. In seiner Freizeit ist er athletisch in der Senkrechten unterwegs und stählt seine Muskeln beim Bouldern. Als richtiger Profi macht er das natürlich am liebsten in der Natur und geht nur noch in Ausnahmefällen in die Kletterhalle.

Sign up for ANSIBLE Automation

Get your OSCamp badge now to Ansibuild your Automation skills!

Meet Anton Vorobiev and learn how to reuse your existing Ansible roles for your Kubernetes apps. Anton will show you how to combine them with the K8s‘ operators.

Learn all about Automated Tests of Ansible code with GitLab, Vagrant, VirtualBox and Ansible from Klaus Franken. The Engineer at ING Germany will introduce you to the triple-A concept! Curious? Join his talk at OSCAMP!

Ansibuild your systems! Don’t miss Toshaan Bharvani showing how roles can build a virtual machine or containers for deployment and much more.

You want to provide End-to-End Automation for the Enterprise?
Check out Nikhil Kathole‘s presentation. The Quality Engineer at Red Hat and upstream contributor demonstrates how Ansible and Foreman integrate!

Get to know how to automate your things and learn best practices, tips and tricks with Ansible!

Find out more at opensourcecamp.de & register now!

Pamela Drescher
Pamela Drescher
Head of Marketing

Seit Dezember 2015 ist Pamela Anführerin des Marketing Teams. Mit ihrer stetig wachsenden Mannschaft arbeitet sie daran, NETWAYS nicht nur erfolgreicher, sondern auch immer schöner zu machen. Privat ist sie Dompteurin einer Horde von drei Kindern, zwei Pferden, drei Katzen und einem Hund. Für Langeweile bleibt also keine Zeit!