In this tutorial, we will show you how to install Ansible on Fedora 35. For those of you who didn’t know, Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. Ansible automates and simplifies repetitive, complex, and tedious operations. It’s a free tool written in Python.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Ansible automation tool on a Fedora 35.
Prerequisites
- A server running one of the following operating systems: Fedora 35.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Ansible on Fedora 35
Step 1. Before proceeding, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:
sudo dnf upgrade sudo dnf update
Step 2. Installing Python.
Ansible is written in Python, now we install Python on the Fedora system using the following command:
sudo dnf install python3 sudo dnf install python3-pip
Step 3. Installing Ansible on Fedora 35.
By default, Ansible is available on Fedora 35 base repository. Now run the following command to install it:
sudo dnf install ansible
We can verify the Ansible version by running the following command:
ansible --version
Output:
ansible 2.9.30 config file = /etc/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.8/site-packages/ansible executable location = /usr/bin/ansible python version = 3.9.8 (default, Dec 10 2021, 00:11:01) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
Step 4. Testing Ansible.
Now we create the key pair using the ssh-keygen
command on your Fedora:
ssh-keygen
Output:
Generating public/private rsa key pair. Enter file in which to save the key (/home/idroot/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/idroot/.ssh/id_rsa. Your public key has been saved in /home/idroot/.ssh/id_rsa.pub. The key fingerprint is: SHA256:vRdPlegZg1meilana0jQsiTYmariaSnuUQj3g fedora@ip-10-2-40-54.us-east-4.compute.internal The key's randomart image is: +---[RSA 3072]----+ | oo . | | o.ooo+ o| | .o+*O=o*.| | ooE**=B..| | S++X+=o. | | =+.=o..| | . . o..| | . | | | +----[SHA256]-----+
Next, copy the id to the remote server:
ssh-copy-id fedora@192.168.77.21
After that, create an inventory file as follows on a control machine:
nano hosts
Add the following file:
192.168.77.21 ansible_ssh_user=fedora
Finally, use the ping module to test ansible:
ansible -i hosts 192.168.77.21 -m ping
Output:
192.168.77.21 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
Congratulations! You have successfully installed Ansible. Thanks for using this tutorial for installing the Ansible automation tool on your Fedora 35 system. For additional help or useful information, we recommend you check the official Ansible website.