HOW TO INSTALL ANSIBLE: Step-By-Step Guide

HOW TO INSTALL ANSIBLE
Image by Freepik

There are multiple configuration management solutions accessible to developers to help with remote server management; however, Ansible stands out for several reasons. What then distinguishes Ansible from other configuration management tools? This is because it is an agentless tool, there is no need to install agents on each node you run. It is indeed a solution that automates cloud supply, configuration management, application deployment, orchestration, and a variety of other important IT requirements. It is necessary to have two machines when installing Ansible. Let us name our first machine ‘Server,’ which will serve as our managed node, and our second machine ‘Node,’ which will serve as our controller node. Now, let’s get started and learn everything there is to know about installing Ansible.

Install Ansible

Overall, Ansible is an agentless automation tool installed on a single host called the control node. Ansible, on the other hand, can remotely manage multiple machines and devices using SSH, Powershell remoting, and other transports from a command-line interface without needing databases or daemons. Ansible automates remote system management and controls the desired state. A basic Ansible environment consists of three main components:

1. Control Node.

The first step is to run Ansible commands on a control node. You can use any UNIX-like machine with Python 3.9 as your Ansible control node. The supported operating systems are Red Hat, Debian, Ubuntu, macOS, BSDs, and Windows under a Windows Subsystem for Linux (WSL) distribution. Windows without WSL does not support it as a control node. 

2. Managed Node. 

Ansible controls a distant system, often known as a host. The managed node does not need Ansible installed; nevertheless, it requires Python 2.7 or Python 3.5–3.11 to run Ansible-generated Python code. The managed node likewise requires a user account for SSH access with an interactive POSIX shell.

3. Inventory. 

Inventory is a list of managed nodes in orderly manner. Moreover, one or more ‘inventory sources’ offer a list of managed nodes. Your inventory can include information specific to each node, such as an IP address. Additionally, it is also used to assign groups, which allow for node selection in the Play as well as bulk variable assignment. A ‘hostfile’ is another name for an inventory source file.

Install Ansible in Simple Steps

1. Download the Ansible binaries for your operating system from the Ansible website.

2. Install the binary into your computer.

3. Make a configuration file for Ansible. The configuration file is a text file that contains the Ansible installation settings. 

4. Create a playbook. A playbook is a text file containing instructions for Ansible to follow. More information on creating a playbook may be found in the Ansible documentation.

5. Run through the playbook. The playbook will execute the instructions and complete the tasks that you have provided. The Ansible manual contains more information on how to run a playbook.

How to Install Ansible 

Ansible is a powerful automation tool for controlling a variety of computer systems. To install Ansible, download the binaries from the Ansible website and run it on your system. A playbook and Ansible configuration file will also be required. Your Ansible installation’s settings may be found in the configuration file, although the playbook houses the commands you want Ansible to carry out. Finally, when you are through making these documents, you can run the playbook to put their contents into action.

1. Installing and Upgrading Ansible Using Pipx.

Some systems may not allow Ansible installation with pip due to OS developer decisions. Pipx is a popular alternative in these cases. For pipx installation instructions, please refer to the separate guide.

Installing Ansible.

1. Install the full Ansible package using pipx.

  • Install Ansible and its interconnections using pipx: Run the command“` pipx install –include-deps ansible `

2. Install minimal ansible-core package.

  • Install ansible-core using pipx.

3. You can install a specific version of ansible-core.

  • Install Ansible Core version 2.12.3 using pipx.

2. Installing and Upgrading Ansible Using Pip.

In this method, locate Python. Find and remember the path to the Python interpreter for running Ansible. Use Python 3 for the following instructions:

Ansible Installation

1. Install the whole Ansible package for the current user using pip in your preferred Python environment:

  •  pip install –user ansible python3

2. For the current user, you can install the minimal ansible-core package: Run the command

  •  pip install –user ansible-core python3

3. You can also install a specific version of ansible-core:

  •  pip install –user ansible-core==2.12.3 python3

Confirming Installation.

1. To test Ansible installation, check the version: 

  • ansible –version

2. This command displays the version for the installed ansible-core package.

3. Check the installed version of the Ansible package.

  • ansible-community –version

Install Ansible Ubuntu 

Ansible can be installed on any *nix-based operating system. Ubuntu is one of the most popular options available. Let’s get the process started by going over how to make it happen.

1. Use your preferred SSH client to connect to your soon-to-be Ansible controller on an Ubuntu host.

2. Ansible is packaged, downloaded, and installed using the apt package manager. Run an apt update to ensure that apt can detect the correct source and download any dependent packages.

3. Install Ansible by installing the software-properties-common package. Install software-properties-common using sudo apt.

4. Thereafter, as an apt repository, add the ansible/ansible personal package archive (PPA). As a result, this repository is handled by Red Hat rather than Ubuntu sources, you must manually add it. 

You can use this command to do it: sudo apt-add-repository –yes –update ppa:ansible/ansible

5. At this point, use the apt install command to install the ansible package. 

6. When complete, execute the Ansible –version command to ensure Ansible is installed. If everything is in order, run the command ansible–version

Install Ansible on Windows 

Ansible is specifically a solution for managing and monitoring remote servers that use infrastructure as code. Ansible, therefore, must be operated on a Linux-based system. If you wish to use its features on a Windows 10 PC, this can be a problem. Evidently, there are, however, ways to install Ansible on Windows. This section, will in like manner go over various methods for installing Ansible on Windows 10.

Here are the steps on how to install Ansible on Windows:

1. Install the Windows Subsystem for Linux (WSL).

2. Open a WSL terminal and run the following command:

  • pip install –user ansible

3. To confirm that Ansible is installed, run the following command:

  • ansible –version

Method 2: Using Cygwin

Overall, Cygwin is a POSIX-compliant environment that allows you to run Unix-like operating system tools and programs on Microsoft Windows. Ansible is not included in the normal Cygwin installation, despite the fact that it contains hundreds of utilities for Unix-based systems. During the installation procedure, you must manually add Ansible.

Follow these instructions to install Ansible on Windows using Cygwin:

1. Save the Cygwin installation file to your computer. This file works with both 32-bit and 64-bit versions of Windows 10. It will eventually install the appropriate version for your system.

2. Double-click the Cygwin installation file. To proceed, click Next on the installation wizard’s first screen.

3. Click Next after selecting Install from the Internet as the download source.

4. In the Root Directory section, enter the location of the programme, then click Next.

5. Select where you wish to install your Cygwin packages in the Local Package Directory area, then click Next.

6. Select the proper Internet connection option.

7. Click Next after selecting one of the available mirrors to download the installation files.

8. Change the View option on the Select Packages screen to full screen and type ‘ansible’ into the search bar.

9. You can review the installation settings on this screen. Click Next to confirm and begin the installation procedure.

10. The whole process will download and install all of the packages you’ve chosen, including Ansible.

11. After the installation is complete, select whether you want to add a Cygwin desktop and Start Menu icon, then click Finish to exit.

Install Ansible on Linux

Here are the steps on how to install Ansible on Linux:

1. Make sure that you have the necessary prerequisites installed before installing Ansible. These prerequisites however, vary depending on your distribution of Linux.

2. Install the Ansible package. This can be done using your distribution’s package manager.

3. Verify that Ansible is installed and working correctly by running the following command:

  • ansible –version

If Ansible is installed and working correctly, you should see the following output:

  • ansible 2.12.3

You can now start using Ansible to manage your IT infrastructure. For more information, please refer to the Ansible documentation.

How to Install Ansible on CMD? 

  • Install Python. Getting Python running on Windows is the first order of activity.
  • Set up pip. After getting Python set up, you’ll want to get the Python package management, pip.
  • Put Ansible to work.
  • Configure Ansible for use. 
  • Evaluate Ansible.

How to Install Ansible Using Pip?

Here are the steps on how to install Ansible using Pip:

  • Make sure that you have Python 3 and Pip installed on your system.
  • Open a terminal and navigate to the directory where you want to install Ansible.
  • Run the following command to install Ansible: pip install ansible
  • Verify that Ansible is installed and working correctly by running the following command: ansible –version

If Ansible is installed and working correctly, you should see the following output: ansible 2.12.3

How to Install Ansible Using Apt? 

  • Log in to the Ubuntu Server that will host Ansible.
  • Install the required repository by running sudo apt-add-repository ppa:ansible/ansible.
  • Use the command sudo apt-get update to update apt.
  • Use the command sudo apt-get install ansible -y to install Ansible.

How Do I Know If Ansible Is Installed? 

To know if Ansible is installed, you can run the following command:

  • ansible –version

If Ansible is installed and working correctly, you should see the following output:

  • ansible 2.12.3

Here are some additional tips:

  • Make sure that you have the necessary prerequisites installed before installing Ansible. These prerequisites vary depending on your operating system.
  • If you are installing Ansible on a Windows system, you will need to install the Windows Subsystem for Linux (WSL) first. WSL is a compatibility layer that allows you to run Linux software on Windows.

Which Command Is Used to Install Ansible? 

Run the following command from your control node to add the official project’s PPA (personal package archive) to your system’s list of sources: sudo apt-add-repository ppa: ansible/ansible.

How Do I Start Ansible in Linux? 

To start Ansible in Linux, you can follow these steps:

  • Make sure that you have Python 3 and Pip installed on your system.
  • Open a terminal and navigate to the directory where you want to install Ansible.
  • Run the following command to install Ansible: pip install ansible
  • Verify that Ansible is installed and working correctly by running the following command: ansible –version
  • If Ansible is installed and working correctly, you should see the following output: ansible 2.12.3

Where Can I Install Ansible? 

You can install Ansible in one of the following ways: Install the most recent version using your operating system’s package manager (for Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu). Moreover, you can install using pip (the Python package manager).

Can We Install Ansible Without Python?

Except for the raw and script modules, all ansible operations require Python, however, on the destination node. Please keep in mind that these two modules are basically intended to install ansible needs (i.e. Python and its mandatory modules) on targets that lack them.

Conclusion

In summary, the prior explanation concludes the article on the topic of ‘Ansible Installation’. In this section, we have acquired knowledge regarding the nature and performance of Ansible, as well as the process of installing the Ansible management tool. If you are installing Ansible on a Windows system, you will need to install the Windows Subsystem for Linux (WSL) first. WSL is a compatibility layer that allows you to run Linux software on Windows. Once you have installed Ansible, you can start using it to manage your IT infrastructure. Ansible can be used to automate a wide variety of tasks, such as provisioning servers, configuring software, and deploying applications.

  1. ANSIBLE VS TERRAFORM: What Are Key Differences?
  2. SCALE COMPUTING: Profile, Features, Reviews & Alternatives 2023
  3. APT-GET UPDATE VS APT-GET UPGRADE: Whats the Difference?
  4. AZURE DATA FACTORY: What It Means & All to Know

References

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like