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
2
sudo apt-get update
sudo apt-get upgrade -y
Install Ansible using Ansible repos
1
2
3
4
sudo apt-get install software-properties-common
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
Confirm installation
1
2
3
4
5
6
7
8
9
10
11
$ ansible --version
ansible [core 2.13.7]
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/dist-packages/ansible
ansible collection location = /home/dave/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
jinja version = 3.0.3
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
ansible all -m ping