Ansible is a powerful automation tool that allows you to configure, deploy and manage Linux servers. It’s often used by DevOps teams, but it can be used for any kind of server or infrastructure management project on any operating system. You will learn how to quickly set up Ansible with your favorite distribution in order to start automating tasks as soon as possible!
The “brew install ansible” is a guide that will help you setup Ansible on your system. It includes instructions for Ubuntu, RHEL, CentOS, and macOS.
If you have a lot of hosts to handle, it’s time to use Ansible to automate configuration management. Ansible is the most popular automation tool for managing configuration changes on-premises and in the cloud.
This post will teach you how to download and install an Ansible controller host on Ubuntu, RHEL, and macOS from the ground up. You’ll also have an advantage when it comes to executing your first commands!
This guide will utilize Ansible version 2.9.20, however the method for installing Ansible on a controller server should be similar for subsequent versions.
Let’s get this party started!
Getting Started with Ansible on Windows: A Step-by-Step Guide
Ansible installation on Ubuntu
Any *nix-based operating system may be used to install Ansible. Ubuntu is one of the most popular options available. Let’s get this lesson started by going through the steps to make it happen.
This tutorial assumes you have an Ubuntu 18+ system with Python2 or above installed if you want to set up Ansible on Ubuntu. This course will use Python 3 and Ubuntu 18.04.5 LTS.
1. Use your chosen SSH client to connect to your soon-to-be Ansible controller on an Ubuntu server.
2. Ansible is available as a package that can be installed using the apt package management. Run apt update to ensure that apt can detect the correct source and download any dependent packages.
The apt or apt-get tool installs packages from Ubuntu’s specified apt software repositories.
3. Install the software-properties-common package to prepare apt to download and install Ansible. install software-properties-common install software-properties-common sudo apt install software-properties-common
install software-properties-common sudo apt install software-properties-common
Using the apt command to install the package
4. Finally, as an apt repository, add the ansible/ansible personal package archive (PPA). Because this repository is handled by Red Hat rather than Ubuntu sources, you must manually add it.
ppa:ansible/ansible sudo apt-add-repository —yes —update
Ansible PPA repository has been added.
5. Now, use the apt install command to install the ansible package.
6. Run the ansible —version command to verify that Ansible has been installed. If everything is in order —version
Taking a look at the Ansible version
RHEL Ansible Installation
Ansible supports a variety of operating systems in addition to Ubuntu. RHEL (Red Hat Enterprise Linux) and CentOS (CentOS) are other popular choices. Let’s take a look at RHEL first.
If you wish to continue this part, make sure your host is running RHEL 8+ (this article will utilize RHEL 8.3). (Ootpa).
1. Use your chosen SSH client to connect to your RHEL server through SSH.
2. Use dnf to install the python3-pip and python3 packages. Python2 is supported by Ansible, however Python3 will be used in this lesson since Python2 will soon be deemed obsolete.
dnf install python3 python3-pip -y sudo dnf install python3 python3-pip -y sudo dnf install p
python3 and python3-pip are installed.
3. Add the EPEL (Extra Packages for Enterprise Linux) repository to your system. The EPEL repository has a variety of system packages, including the Ansible package, which you’ll install next.
dnf -y install sudo https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
EPEL repository has been added.
4. After you’ve installed the repository, reference the appropriate EPEL repository and the package’s name to install the Ansible package (ansible). The dnf program will download the most recent version of Ansible for you.
sudo dnf install epel-playground —enablerepo ansible
5. Run ansible to verify that Ansible was successfully installed.
Taking a look at the Ansible version
CentOS Ansible Installation
Let’s finish off the *nix hosts by installing Ansible on CentOS.
Make sure you have a CentOS 7+ system with Python2 or above installed if you wish to continue this step (this tutorial will use CentOS 7.9.2009 Core).
1. Use your chosen SSH client to connect to your CentOS server through SSH.
2. Add the EPEL (Extra Packages for Enterprise Linux) repository to your system. The EPEL repository has a number of system packages, including the Ansible package, which you’ll install next.
# yum install epel-release yum install epel-release yum install epel-release yum install epel-release yum install epel-release yum install epel-release yum install epel-release yum install epel-release y
Using the official Red Hat software repositories as well as other third-party repositories, the yum program installs and maintains software.
Using the yum command to install the epel-release package
3. Install the Ansible package when the repository is finished.
Ansible package installation
4. Run ansible —version to verify that Ansible is installed.
Taking a look at the Ansible version
Ansible for macOS installation
You’ve learnt how to install Ansible on a variety of Linux distributions so far. Let’s wrap off this guide by looking at how to set up Ansible on a Mac.
This portion of the class will cover Homebrew, a popular macOS package management. The simplest method to install Ansible on macOS is to use Homebrew. On macOS Catalina, this guide will use Homebrew v3.0.7.
Check out the Ansible pip package if you want to learn how to install Ansible using the popular Python package manager pip.
To install on Mac OS X, follow these steps:
- Open the Apple Terminal application.
- To download and install Ansible on your Mac, run the following line in Homebrew.
- After that, run ansible —version to make sure Ansible is installed.
config file = None configured module search path = [‘/Users/shanky/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’] $ ansible —version ansible 2.7.5 /usr/local/Cellar/ansible/2.7.5/libexec/lib/python3.7/site-packages/ansible ansible python module location = /usr/local/bin/ansible python version = 3.7.2 ansible executable location = /usr/local/bin/ansible (default, April 13 2021, 07:35:52) [clang-1000.11.45.5)] Clang 10.0.0 (clang-1000.11.45.5)
Putting Ansible to the test by issuing ad-hoc commands
Now that Ansible is installed, it won’t help you much until you utilize it! Learning about ad hoc commands is one of the simplest ways to get started with Ansible. Ad hoc commands are one-time, generally single-line instructions executed by Ansible on distant machines (or on the Ansible host in this example).
Running ad-hoc Commands on Windows Hosts is a related topic.
Using the -m switch, run an ad-hoc command on your preferred operating system. The -m switch defines an Ansible module with a variety of features.
The ping module is one of the most basic Ansible modules. This module checks the Ansible controller’s and a host’s connection. Provide the name of the Ansible controller itself (localhost) to execute the ping module against if you don’t have any remote hosts accessible.
ping ansible localhost -m
If everything went well, you should see green output.
The ansible ad hoc ping module is being used.
You learnt how to install Ansible, the most extensively used automation tool, on Ubuntu, RHEL, CentOS, and macOS in this article.
What do you intend to do with your new Ansible controller host now that it’s up and running?
This guide will show you how to install Ansible on a RHEL 7 server. This is the same process that can be followed for Ubuntu, CentOS, and macOS. Reference: install ansible on rhel 7.
- ansible install ubuntu
- install ansible mac
- how to configure ansible in linux
- yum install ansible
- install ansible centos 7