By clicking or navigating this website site, you agree to allow our collection of information on Scaleway to offer you an optimal user experience and to keep track of statistics through cookies. Learn more about our Cookie Policy.

How to Install Ansible on Ubuntu Bionic Beaver

Ansible Overview

Ansible is an IT automation tool. It simplifies cloud computing, configuration management, program setup, intra-service orchestration, and several other IT needs.

Ansible uses a very simple language (YAML, in the form of Ansible Playbooks) that allows you to spell out your automation jobs in a way that means plain English.

While there are many popular configuration management systems available for Linux systems, such as Chef, Ansible is the simplest configuration management systems to get started with.

Ansible works by configuring client machines from a computer that has the Ansible components installed and configured. It communicates over normal SSH channels to retrieve information from remote machines. This means that any computer that you can administer through SSH, you can also administer through Ansible.

Installing Ansible 2.6 on Ubuntu Bionic Beaver

1 . Connect to your server using SSH:

ssh root@SERVER_IP

If you do not know your server IP, you can list your existing servers using scw ps (Scaleway CLI). For more information on the Scaleway CLI, refer to the tutorial on the Scaleway Command Line Interface.

The server IP can also be retrieved from the Scaleway Console. Once logged in, check the IP Adresses in the Servers tab of the left menu.

Note: If you use the root user, you can remove the sudo before each command.

2 . Update Ubuntu packet manager:

sudo apt-get update

3 . Upgrade the Ubuntu packages already installed:

sudo apt-get upgrade

Installing Ansible from PPA repository

1 . Update your package index and install the software-properties-common package. This software will make it easier to manage this and other independent software repositories. Add the Ansible PPA and refresh your system’s package index once again.

9 . IMPORTANT: Under Credentials Paste your SSH key in the Scaleway Console and click Use this SSH Key

10 . Run the exit command to close the connection to the client

Repeat this process for each server you intend to control with your Ansible server. Next, we’ll configure the Ansible server to connect to these hosts using Ansible’s hosts file.

Configuring Ansible Hosts

1 . Ansible tracks of all of the servers through an inventory file. We need to set up this file first before we can communicate with our other computers.

On your Ansible server, open the file

sudo nano /etc/ansible/hosts

In our example, we have two servers controlled with Ansible. The hosts file is fairly flexible and can be configured in a few different ways. The syntax we are going to use, though, looks like this:

[group_name]
alias ansible_ssh_host=your_server_ip

In this example, group_name is an organizational tag that lets you refer to any servers listed under it with one word, while alias is just a name to refer to one specific server. For the tutorial purpose, our host file looks like this:

If you want to specify configuration details for every server, regardless of group association, you can put those details in a file at /etc/ansible/group_vars/all. Individual hosts can be configured by creating files named after their alias under a directory at /etc/ansible/host_vars.