Installing Ansible Roles from Galaxy
Galaxy has a role for most things and installing one is a single command. Trusting it is the harder part. This installs a widely used role, reads it before running it, pins it in a requirements.yml - and then runs it and watches it fail, because the package it wants no longer exists on this distribution. The fix is two variables and no changes to the role.
Roles and Collections Guide 27 of 45 Intermediate
- OSUbuntu 26.04 LTS
- ansible-core2.20.1
- Python3.14.4
- TimeAbout 18 min
ansible-galaxy role install and ansible-galaxy collection install read the same requirements.yml but only their own section of it, and they install to different places. A -p path that is not on the configured search path draws a warning and the content will not be found at run time unless it sits beside the playbook.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| ANS-CTL01 | 192.168.0.36 | Ubuntu 26.04 LTS | Ansible Control Node | 2 Core | 3 GB | 50 GB |
| ANS-A01 | 192.168.0.37 | Ubuntu 26.04 LTS | Managed Node (group: web) | 2 Core | 3 GB | 50 GB |
| ANS-B01 | 192.168.0.38 | Ubuntu 26.04 LTS | Managed Node (group: db) | 2 Core | 3 GB | 50 GB |
This guide includes
Use this before running someone else's code as root on your hosts. This matters because a role can claim to support your platform in its metadata and still fail on it - so reading it first is the point, not the install command.
- installing a role from Galaxy in a single command
- reading a role before trusting it with root
- pinning it in a requirements file, with a version
- finding where things landed, past the path warning
- watching it install and still fail, then overriding what the role guessed
Before you start
- A control node with network access to galaxy.ansible.com.
- The session installs
geerlingguy.ntpinto~/pb/roles/and applies it toans-b01, which ends with chrony running and the timezone set.
-
The configuration this guide assumes
-
Installing one role
-
Reading a role before you trust it
-
A requirements file
-
Where things landed
-
It installs, and it still fails
-
A role can claim a platform and still fail on it
-
Override what the role guessed