How to install Ansible

https://www.snel.com/support/how-to-install-ansible-on-centos-7/


Install Ansible on Ubuntu

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

Install Ansible on Centos

# NOTE: Before installing Ansible you may need to install the epel-release repo
# for RHEL or
# Scientific Linux. Additional details on how to install EPEL can be found at
# http://fedoraproject.org/wiki/EPEL
$ sudo yum install ansible

For Gentoo Linux users, installing Ansible can be accomplished fairly easily. The following command-line syntax can be leveraged to accomplish the installation:

# The first command is optional, you may need to unmask the Ansible package prior to running emerge:
$ echo 'app-admin/ansible' >> /etc/portage/package.accept_keywords
$ emerge -av app-admin/ansible

PKG for FreeBSD

FreeBSD-specific users can use pkg install to install the Ansible control server solution and get Ansible up-and-running quickly:

$ sudo pkg install ansible

Pip for macOS

The preferred way to install Ansible for macOS is to use Python's pip installation solution. An example of how to do this is provided next.

If needed, you can install pip via the following command:

$ sudo easy_install pip

Once pip is installed, you can install Ansible with the following command:

$ sudo pip install ansible

Via Python pip

Prior to installing Ansible using pip we may need to actually install pip. To accomplish this on the command line, the following command can be used:

$ sudo easy_install pip

Then install Ansible with the following command:

$ sudo pip install ansible

Once Ansible has been installed

Once Ansible is installed on the desired Linux machine, we will want to verify that it is properly installed and functioning. To do this from the command line, enter the following command:

# Display Ansible command line options available
$ ansible --help
# Show the Ansible version number
$ ansible --version

Upon successful execution of these commands, Ansible should output version information and related help information respectively.

In this brief tutorial we will assume the SSH key authentication solution is being used. It helps us avoid having to enter or store raw passwords:

$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa

Now ping all the nodes (assumes you have an inventory file created):

$ ansible all -m ping

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch