Part 1 – Getting Started with Ansible for Aria Automation

Loading

Ansible is an agentless Orchestrator and an Automation tool that makes Linux/Windows applications and systems easier to provision, deploy, and do configuration management tasks. In this blog, we will focus on installing Ansible on our Redhat 9 and this install will form the base for our Aria Automation stack we will build on later during our journey.

During the tour, we will install Ansible Tower on our RHEL 9 System which takes Ansible to the next level by introducing a web-based infrastructure automation platform for centrally managing and configuring all our Linux/Microsoft Windows Servers via the UI. Ansbile tower is free for usage for up to 10 nodes so we can deploy with just a trial subscription from Redhat.

Note: With Redhat 9 and above, the Ansible Core package is by default included in the AppStream repository so there is no longer a requirement to add an EPEL repository that was very commonly used with previous RHEL 8 and below versions.

Components of Ansible Engine

  • Control Node – Also known as the brain of the system that has Ansible installed.
  • Managed Node – These are the clients in simple terms.
  • Host Inventory – List of all hosts that can be managed with Ansible eg: Webservers
  • PlayBooks – are a set of group-related tasks that are to be executed on a managed node eg; Prod Dev, etc
  • Modules – ready-to-use codes that help in package installation, file manipulation and service management that are run when a playbook is run. Modules are stored in the /lib/ansible/modules.

Ansible Tower (AWX) Deployment Prerequisites

With Redhat 9 and above, the Ansible Core package is by default included in the AppStream repository so there is no longer a requirement to add an EPEL repository that was very commonly used with previous RHEL 8 and below versions.

Installing Ansible on Red Hat 9

Refresh the yum cache by running the following command;

Update all software packages on the system using dnf update –y

To list all repositories on the VM, run dnf repolist . Ansible Core package is by default included in the AppStream repository in RHEL9

Install Ansible with dnf command

Verify the Ansible version

Verify the Python version

We will need to create a normal Linux user for Ansible Node Management. In this example, i’ve choosen ariaadm.

We will allow Linux users to run any commands anywhere by adding an entry in /etc/sudoers, this entry should be an all-managed server as well for Ansible to execute commands as a admin user if necessary.

The below option can be used in case we wish to input a password following the execution of an Ansible command

Generate SSH keys for the ariaadm user

Copy the ssh key on every Ansible-managed node for us to do password-less login to all servers managed with Ansible via SSH.

The main configuration files on ansible are under /etc/ansible. The two important files in here are the /etc/ansible/hosts (also known as inventory file), etc/ansible/ansible.cfg ( also known as config file). Update lists of hosts to be managed by ansible into an inventory file or the host’s file below.The default location for the host inventory file is /etc/ansible/hosts.

Create an inventory file and add all the hosts that are managed by Ansible in this format.

Tweak the following parameter in Ansible config file /etc/ansible.cfg to enable privilege escalation that will enable us to run commands as root

Run the following Ansible command to perform an Ansible check from the control node to the managed node

Prefix the above Ansible command with –become to perform an Ansible check from the control node to the managed node elevating us as a root user.

If we wish to type a password following the execution of a command we use the option K

(Visited 33 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.