Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. T&Cs apply

Configuration Management with Ansible

An introduction to Ansible, an open-source configuration management and automation tool
In the previous step, we learned about the management of the configuration of all environments for an application. In this step, we will explore Ansible as a configuration management and automation tool. It’s an open-source tool based on Python.

It uses declarative YAML configuration files called playbooks to describe a state or a policy that you want your remote systems to enforce, or execute. Playbooks are Ansible’s configuration, deployment, and orchestration language.

Ansible uses Secure Shell (SSH) to execute commands on remote machines which makes it agent-less. It ships with a number of modules that can be executed directly, remotely, or through Playbooks.

These modules are reusable components that can be used by Ansible API, or by Ansible or Ansible Playbook programs. Developers can also create their own modules.

Ansible cloud modules are used to automate different tasks like cloud provisioning and workloads automation. Ansible supports different public clouds like Azure.

Using these modules and Playbook language, you can provision and manage the lifecycle of a virtual machine (VM) in Microsoft Azure, manage different services and resources such as availability sets, auto-scaling policies, Azure Container Service, Azure DNS, Azure Function Apps, Azure load balancers, disks and network interfaces.

Below is an example of a playbook that creates an Azure VM and configures SSH credentials.

- name: Create Azure VM
hosts: localhost
connection: local
tasks:
- name: Create VM
azure_rm_virtualmachine:
resource_group: myResourceGroup
name: myVM
vm_size: Standard_GS5-8
admin_username: azureuser
ssh_password_enabled: false
ssh_public_keys:
- path: /home/azureuser/.ssh/authorized_keys
key_data: "ssh-rsa CCDDV2aZ...WXhad10h"
image:
offer: UbuntuServer
publisher: Canonical
sku: '16.04-LTS'
version: latest

You can add other configurations for your VM in the same playbook, for instance, creating a Network Security Group that allows SSH, creating a virtual network interface card that uses this Security Group and attaching this network interface to your VM.

Remember to engage with peers or post comments then click on Mark as complete. In the next step, we will discover configuration management with SaltStack

This article is from the free online

Microsoft Future Ready: Fundamentals of DevOps and Azure Pipeline

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now