Tuesday, January 2, 2018

What is Ansible?


Ansible is an open source IT Configuration Management, Deployment & Orchestration tool. We can use Ansibles to automate cloud provisioning, configuration management, application deployment, intra-service orchestration etc. Ansible was bought by Red Hat in October 2015, it is now referred to as Ansible by Red Hat.

Ansible uses Playbooks for express configurations, deployment, and orchestration.

The Playbook format is YAML each and Playbook maps a group of hosts to a set of roles. Each role is represented by calls to Ansible tasks. Ansible does not require an agent on the host system for SSH. As long as Ansible can make an SSH connection to the target device, we should be good. Ansible is primarily used for server & network administration. 

There are two versions for Ansibles, free and paid. The paid version is called Ansible Tower which is an enterprise framework for controlling, securing and managing your Ansible automation with a GUI and Restful API.


Here I will show you how to install Ansible on Ubuntu Server.

I'm using Ubuntu 16.04 to install Ansible on my VMWorkstation but you can use any Linux OS.

1 - Installing Ansible

The best way to get Ansible for Ubuntu is to add the project's PPA (personal package archive) to your system.

sudo apt-add-repository ppa:ansible/ansible

You will need to press ENTER to accept the PPA addition.

Next, we will refresh our system's package index so that it is aware of the packages available in the PPA. 

sudo apt-get update
sudo apt-get install ansible

Once it's completed, run the below command to verify the Ansible version

ansible --version

2 - Configuring Ansible Hosts

Ansible keeps track of all of the servers that it knows about through a "hosts" file. We need to set up the Ansible Host file.

Open the file with root privileges:

sudo nano /etc/ansible/hosts

You will see a file that has a lot of example configurations, none of which will actually work.  Let's comment out all of the lines in this file by adding a "#" before each line. Once all of the lines are commented out, we can begin adding our actual hosts.

[group_name]
variable ansible_ssh_host=server_ip

In this example, we have a server which we are going to control with Ansible. We can access the server from Ansible by typing below command:

ssh root@server_ip
[servers]
HostA ansible_ssh_host=10.10.10.1
hostB ansible_ssh_host=10.10.10.2
hostc ansible_ssh_host=10.10.10.3
If you want to enable colorful terminal in Ubuntu, below are the commands:

Edit the file .bashrc in your home directory:

vim .bashrc

Uncomment the line that says ‘force_color_prompt=yes’ and save it. Then type the following:

source ~/.bashrc

Done!

Ansible is a very powerful tool and is going to change the way of automation in future.

I hope this will be helpful for you. This was a simple tutorial and there will be more to come.

No comments:

Post a Comment

Introduction to Virtual Private Network - VPN

VPN Tutorial Guide A VPN (Virtual private network) is a secure connection between two or more endpoints. It can also be seen as an ex...