Skip to main content

Ansible Tower on Rocky Linux

Ansible

Installing Ansible is a prerequisite for installing Tower, so those steps are detailed.  Ansible works by configuring client machines from a computer with Ansible components installed and configured. It communicates over normal SSH channels to retrieve information from remote machines, issue commands, and copy files.  An Ansible system does not require any additional client software. 

Installing Ansible on Rocky Linux 9.2

sudo dnf install epel-release
 sudo dnf install ansible
 sudo vi /etc/ansible/hosts
[group_name]
alias ansible_ssh_host=<your_server_ip>

Example:
[servers]
server1 ansible_ssh_host=10.0.2.111
server2 ansible_ssh_host=10.0.2.112
server3 ansible_ssh_host=10.0.2.113

The group_name is an organizational tag that lets you refer to any servers listed under it with one word. The alias is a name to refer to that server. Hosts can be in multiple groups and groups can configure parameters for all of their members.

For this example the host servers will be newly created VirtualBox VMs using this Rocky Linux 9.3 minimal ISO

image.png

The VirtualBox VMs can be configured like this:

These will be "headless" servers, meaning they will not have a GUI interface.  Ansible will interact with them over ssh connections.  During the installation select the option to allow the root user SSH access.  We will also create a non-root user with admin privileges for use by Ansible.  

The default network configuration is DHCP.  We will change that to a manual configuration.  We will set this and the IP, gateway, and hostname using the command:

nmtui
VirtualBox server1

nmtui network connection on server1
VirtualBox uses Network Address Translation (NAT) to host the VM network. While VirtualBox itself may be on a 192.168.1.x/24 network, the VMs will be on 10.0.2.x/24.  The server1 IP address is 10.0.2.111 and the VirtualBox gateway is 10.0.2.2.  Once the network details are set, reboot the VM.  Log in and run these commands to verify network configuration and functionality. 
hostname
 ip a
 ping www.google.com
server1 networking details

We will add a new user, set the password, then add the user to sudoers.

useradd ansible_user
passwd ansible_user
echo "ansible_user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/80-ansible-sudo-user

Power down server1 using the command

shutdown -h now