AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible Galaxy: Complete Guide to Collections, Roles, and Publishing

By Luca Berton · Published 2024-01-01 · Category: installation

Master Ansible Galaxy: install collections and roles, manage dependencies, create and publish your own content, use requirements.yml, configure private Galaxy servers, and integrate with Automation Hub.

What Is Ansible Galaxy?

Ansible Galaxy is the community hub for sharing Ansible content — collections and roles that you can download and use in your automation. Think of it as npm for Ansible. • Galaxy website: — browse and search collections • ansible-galaxy CLI: Install, create, and manage collections and roles • Automation Hub: Red Hat's curated, certified content (requires AAP subscription)

Install Collections

From Galaxy

From requirements.yml

From Private Galaxy Server

Install Roles

Role requirements.yml

Create a Collection

Scaffold

galaxy.yml

Add a Custom Module

Add a Custom Filter

Usage:

Add a Role to Collection

Build and Publish

Build

Publish to Galaxy

Publish to Automation Hub

Publish to Private Galaxy (Pulp)

Create a Role

Role meta/main.yml

Dependency Management

Pin Versions for Reproducibility

Use Collections Path

Search Galaxy

FAQ

What's the difference between collections and roles?

Collections are the modern packaging format that can contain modules, plugins, roles, and playbooks in a single distributable unit. Roles contain only tasks, handlers, files, templates, and variables. Collections replaced standalone roles as the recommended distribution method.

How do I choose between Galaxy and Automation Hub?

Galaxy is free and community-maintained — anyone can publish. Automation Hub is Red Hat's curated repository with certified, supported content included with AAP subscriptions. Use Galaxy for community content and Automation Hub for enterprise-supported content.

Should I use ansible-galaxy install or ansible-galaxy collection install?

Use ansible-galaxy collection install for collections and ansible-galaxy role install for standalone roles. The plain ansible-galaxy install with a requirements.yml handles both if your file has both collections: and roles: sections.

How do I keep collections updated?

Run ansible-galaxy collection install -r requirements.yml --force periodically. For CI/CD, pin exact versions in requirements.yml and update deliberately. Use Dependabot or Renovate to automate version bump PRs.

Can I host a private Galaxy server?

Yes. Use Pulp with the galaxy_ng plugin or Automation Hub (included with AAP). Private Galaxy servers let you host proprietary collections, mirror public content, and control what's available to your organization.

Conclusion

Ansible Galaxy is the ecosystem that makes Ansible powerful — thousands of community collections and roles ready to use. Install content with ansible-galaxy collection install, pin versions in requirements.yml for reproducibility, create your own collections with custom modules and filters, and publish to Galaxy or a private server. For enterprise content with Red Hat support, use Automation Hub alongside Galaxy.

Related ArticlesAnsible Collections: Install, Use, and CreateAnsible Roles Complete GuideAnsible Documentation Complete GuideAnsible Lint Complete GuideInstall Ansible Complete GuideIntroducing the New Ansible GalaxyCrafting and Publishing Custom Collections on Automation Hub

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home