Home Installing Ansible (Red Hat)
Post
Cancel

Installing Ansible (Red Hat)

No matter your role, or what your automation goals are, Ansible can help you demonstrate value, connect teams, and deliver efficiencies for your organization. Built on open source, Red Hat® Ansible® Automation Platform is a hardened, tested subscription product that offers full life cycle support for organizations. Explore how Ansible can help you automate today—and scale for the future.

Note: “Manager” is the term I use for the Linux machine managing the other machines.

Make sure passwordless SSH login is working from the “manager” machine to all of the machines to be managed. Make sure to test the login and accept the SSH prompt.

Update and Upgrade

1
sudo yum update -y

Install Ansible

1
sudo yum install -y ansible-core

Confirm installation

1
2
3
4
5
6
7
8
9
10
$ ansible --version
ansible [core 2.13.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/dave/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/dave/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True

Inventory file

Create an “inventory” file that will list the machines to be managed. In a Red Hat installation a sample inventory file is located ##at “/etc/ansible/hosts”. Add something like the following, naming your machines to manage:

1
2
3
4
5
6
7
[servers]
u22-a.lan
u22-b.lan
u22-c.lan

[all:vars]
ansible_python_interpreter=/usr/bin/python3

In the inventory file, you can have multiple sections (“[servers]”). You can also have multiple inventory files by using the -i flag.

Inventory files can also be in YAML format as explained here: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html

Ansible configuration file location

1
/etc/ansible/ansible.cfg

Examples

1
2
ansible all -m ping
ansible -i inventory.file all -m ping

“all” is a special keyword to indicate all sections within the same inventory file.

This post is licensed under CC BY 4.0 by the author.