Skip to main content

Command Palette

Search for a command to run...

Setting up Ansible on an Ubuntu platform

Updated
2 min read
Setting up Ansible on an Ubuntu platform
J

I am excited to continue my learning journey in DevOps. I believe that DevOps is the future of software development, and I am excited to be a part of the movement.

Installing Ansible on Ubuntu

Ansible is a powerful automation tool that can be used to manage and configure servers. It is a great way to simplify and automate tasks, and it can save you a lot of time.

Here, I will show you how to install Ansible on Ubuntu. I will also show you a simple task that you can use to test Ansible.

Step 1: Update your system

Always ensure to update your libraries before installing any software

sudo apt update
sudo apt upgrade

Step 2: Install the Ansible repository

Ansible is not available in the default Ubuntu repositories, so we need to add the Ansible repository.

sudo apt-add-repository ppa:ansible/ansible

Step 3: Install Ansible

Now that we have added the Ansible repository, we can install Ansible.

sudo apt install ansible

Step 4: Check Ansible Installed

To check Ansible is installed properly we can run a simple command.

ansible --version

This command will show the version of Ansible installed

If you get an error like "ERROR: Ansible requires the locale encoding to be UTF-8; Detected ISO8859-1"

then run the following command :

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales

Simple task

Now that we have Ansible installed, we can use it to perform a simple task.

Let's say we want to install the Apache web server on all of our hosts. We can do this with the following playbook:

---
- hosts: all
  tasks:
  - name: Install Apache
    apt:
      name: apache2
      state: present

This playbook will install the Apache web server on all of the hosts in our inventory.

To run the playbook, we can use the following command:

ansible-playbook playbook.yml

This command will run the playbook and install Apache on all of our hosts.

Conclusion

In this blog post, I showed you how to install Ansible on Ubuntu. Ansible is a powerful tool that can be used to automate a wide variety of tasks. If you are looking for a way to simplify and automate your server management, Ansible is a great option.

Refer to these resources for more

More from this blog

Jatin Chourasia

49 posts

Goes by the name LegionDev