×
Community Blog Getting Started with Ansible for Configuration Management

Getting Started with Ansible for Configuration Management

In this tutorial, it will explain to use Ansible for deploying and managing your applications on configuration management system.

Ansible is a free and open source configuration management system that allows you to automatically deploy and centrally manage your applications. You can easily manage and control large numbers of servers from central location using Ansible. Ansible is a great alternative solution of Chef and Puppet because it has a much smaller overhead to get started. Ansible uses SSH channels to retrieve information from remote system, so you does not require any additional software to be installed on the client computers.

The biggest challenge for any IT administrator or DevOps engineer is to prepare environments the agile way by making sure that all the environments carry same components all the time.

In some cases, environments are geographically distributed and changes should be rolled out in such a way that it does not impact existing infrastructure and delivered in time to meet the SLO (Service Level Objectives), SLI (Service Level Indicators), and SLA (Service Level Agreements).

Getting Started with Configuration Management and Ansible

This blog post will help you to understand how to configure and manage the infrastructure with identical software/components on each system. The blog post is intended for the readers with some or intermediate IT administration experience.

The blog post will answer the following questions

  1. What is Configuration Management?
  2. How to implement Configuration Management?
  3. What is Ansible?
  4. How can Ansible help in Configuration Management?
  5. What is Ansible Playbook?
  6. How to write Ansible Playbook?
  7. Configuring servers using Ansible Playbook
  8. What is Ansible Galaxy?
  9. Configuring servers using Ansible Galaxy

As defined in Wikipedia, "Configuration Management is establishing and maintaining consistency of a product's performance, functional, and physical attributes with its requirements, design, and operational information throughout its life".

From a DevOps perspective, we need to make sure that the development environment is exactly similar to the production and UAT - User Acceptance Test servers. This will help to reduce to see the different results from the environment to the environment.

The first step to getting started with is to create an inventory of all the requirements. The following is a sample inventory baseline file.

sample inventory baseline file

Now as we have the requirement, the next step is to automate it and we will use Ansible. Ansible is an open source IT automation tool that can improve the stability, reliability, and consistency of the IT infrastructure.

Why Ansible?

  1. Ansible works on the push technology and does not need any special client to install on the remote server. All it needs is an SSH connection.
  2. Ansible has more than 1300 modules and plugins to support web servers, database servers, networking, security, docker, Kubernetes, storage, networking, monitoring and many more.
  3. Ansible has a very big community support.
  4. Ansible is using YAML to get the inputs and configure remote systems
  5. Ansible comes with powerful Orchestration. It can help from a VM provision to application deployment.
    Ansible is easy to learn and adapt. It does not require any special skills to create and execute scripts

Used Blog

How to Install and Use Ansible on Ubuntu 16.04

This tutorial will walk you through the step by step instruction of how to install and use Ansible on an Alibaba Cloud ECS Ubuntu 16.04 server.

Prerequisites

  1. Two Alibaba Cloud ECS instance with Ubuntu 16.04 installed.
  2. A static IP address 192.168.0.103 is configured on server node.
  3. A static IP address 192.168.0.104 is configured on client node.
  4. Root password is configured on each node.

Launch Alibaba Cloud ECS instance

First, Login to your Alibaba Cloud ECS Console. You will be redirected to the main dashboard. You will need to navigate to your ECS instance by selecting the appropriate region. For this tutorial, I have created my ECS instances in the Singapore region.

If you haven't created an instance, you can check out this tutorial or follow the steps on this quick start guide. You will need to have two running ECS instances, preferably on the same region.

Note that I have set up my ECS instances with SSH key pairs as credential. This allows me to connect to the instances using SSH.

Install Ansible

By default, Ansible is not available in Ubuntu 16.04 repository. So you will need to add Ansible personal repository to on the server node. You can add the repository using the following command:

Managing System Users Using Ansible

In this article, we will learn how to manage users using Ansible in an Alibaba Cloud environment. We will start by defining the architecture, as shown in the diagram below.

architecture

The diagram shows an Ansible controller node managing various nodes using SSH protocol. Extending this diagram, we are going to create playbooks that will manage different users with their sudoers privilege in the target node.

To follow this tutorial, you will need to have Alibaba Cloud Elastic Compute Service (ECS) instances. If you are not sure how to launch an ECS instance in Alibaba Cloud, refer to this documentation.

Setting Up Ansible User

Here is a quick guide of creating and setting up ansible user in controller and target nodes.

Ansible User Setup in Controller Node
Create ansible remote user to manage the installation from Ansible Controller node. This user should have appropriate sudo privileges. An example sudoers entry is given below.

Related Products

Elastic Compute Service

Elastic Compute Service provides Elastic and secure virtual cloud servers to cater all your cloud hosting needs.

Simple Application Server

Simple Application Server is a single server-based service for application deployment, security management, O&M monitoring, and more

Related Documentation

Batch migration - Elastic Compute Service

When you want to migrate a large number of servers at a time, it takes an extended period of time if you migrate each server through full data migration. If you have more than 10 servers to migrate, we recommend that you create scripts for batch migration.

Automated O&M tools such as Ansible are typically used to manage a large group of server systems. You can easily complete repetitive operations by using Ansible. For example, you can copy the same file to 100 servers or install and start the Apache service on 100 servers simultaneously.

Install and configure GitLab - Elastic Compute Service

GitLab CE edition is a free open-source tool that helps you host Git repositories and run your CI/CD pipeline.

To keep it simple, you can install GitLab on an ECS instance with a direct access to Internet. Although the servers will be protected via encryption and restrictive security group rules, you might also want to isolate your virtual machines from Internet by using a VPN Gateway.

Related Courses

An Introduction of DevOps

What is DevOps? Its a combination of cultural philosophies, practices, and tools that increases a team’s ability to rapidly deliver services. In this clouder course, you’ll learn the concept and history of DevOps, how it works compared with traditional methodology, tools that support DevOps and recap the ideas with some classic case studies.

Conducting DevOps practices on Alibaba Cloud

In this clouder course, you’ll learn how to conduct DevOps practices on Alibaba Cloud by using Alibaba Cloud services like ECS, some open source tools and GitHub.

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments