Skip to content

Latest commit

 

History

History
339 lines (243 loc) · 10.1 KB

File metadata and controls

339 lines (243 loc) · 10.1 KB

Lab 1: Ansible Overview

Overview of Ansible

Ansible is an open source automation platform that can manage hosts over the ssh protocol. Ansible is described in three words: Simple, Powerful, Agentless. It is considered simple due to providing human-readable automation. The playbooks are written using YAML syntax that requires no coding skills and each task within the playbook is executed in order. Ansible is considered powerful because of its flexibility to automate your entire app lifecycle. Ansible is agentless thus doesn’t require installing anything on the managed remote hosts. It uses OpenSSH or WinRM to run tasks and execute Ansible modules on the managed hosts.

Ansible Architecture

The Ansible architecture consists of two types of machines labeled: Control Machine and Managed Nodes. Ansible is installed on the control machine. The control machine contains all of the playbooks that are to be run against your managed nodes. The managed nodes are listed in an inventory file. The inventory of the managed hosts is either a simple static text file or a dynamic inventory file created by a set of scripts written by the end user to determine the IPs or the hostname of the hosts that are to be managed. For the purposes of this lab, we will use a dynamic inventory script to retrieve information about our OpenStack instances. Ansible inventories include the ability to group nodes together for easier manageability. For example grouping all the database nodes in a group labelled database. The OpenStack dynamic inventory script retrieves group membership from the instance’s metadata.

After Ansible takes the input of the nodes to be managed, a playbook that contains at least one play is executed for the managed nodes that are selected. A play executes a series of tasks in order on the managed nodes. Each task runs a specific Ansible module that is specified within your Ansible playbook. The tasks are what may change the state of the managed hosts as they may install packages on a system, modify files, and/or change configuration settings. For the purposes of this lab, the main focus will be on using OpenStack Ansible modules to manage our OpenStack instances.

A pictorial representation of Ansible’s architecture from the Ansible site can be seen below:

ansible architecture
Figure 1. Ansible Architecture

 

In this lab environment, our control machine is our OVH instance. This instance we will use Ansible playbooks to configure OpenStack instances, create our database backup and provide the ability to restore our database using the playbooks that will be created in the upcoming labs.

The OVH instance should already come with Ansible installed. Confirmation of the installation of Ansible can be done via:

$ ansible --version

Using a text editor

In Linux we will use vi/vim/nano to edit and manipulate files. If using vi/vim, place the following snippet in your ~/.vimrc of your OVH cloud instance to make use of the tab key as 2 spaces.

autocmd FileType yaml setlocal ts=2 sw=2 et