CertGrid CertGrid
Hands-on Lab·Ansible

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

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.

The role is installed on the control node and applied to the `db` host.
Server NameIP AddressOSRolesCPURAMHDD
ANS-CTL01192.168.0.36Ubuntu 26.04 LTSAnsible Control Node2 Core3 GB50 GB
ANS-A01192.168.0.37Ubuntu 26.04 LTSManaged Node (group: web)2 Core3 GB50 GB
ANS-B01192.168.0.38Ubuntu 26.04 LTSManaged Node (group: db)2 Core3 GB50 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.

Before you start

  1. The configuration this guide assumes

  2. Installing one role

  3. Reading a role before you trust it

  4. A requirements file

  5. Where things landed

  6. It installs, and it still fails

  7. A role can claim a platform and still fail on it

  8. Override what the role guessed

Official sources