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: Install Collections & Roles — Complete Guide (2026)

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

Complete guide to Ansible Galaxy. Install collections and roles with ansible-galaxy, manage requirements.yml, create custom roles, publish to Galaxy Hub. Practical command examples.

Ansible Galaxy: Install Collections & Roles — Complete Guide (2026)

Ansible Galaxy is the hub for finding, sharing, and downloading Ansible content. This guide covers everything from installing collections and roles to creating and publishing your own.

What is Ansible Galaxy?

Ansible Galaxy serves two purposes: Galaxy Hub () — a public repository of community-contributed collections and roles ansible-galaxy CLI — the command-line tool to install, create, and manage collections and roles

Installing Collections

Install from Galaxy Hub

Install from requirements.yml

Create a requirements.yml file:

Install all at once:

Install from Git Repository

Install from Tarball

Installing Roles

Install from Galaxy Hub

Install from requirements.yml

Managing Installed Content

List Installed Collections

List Installed Roles

Upgrade Collections

Remove Collections

Collection Installation Paths

Default locations (in priority order):

Configure in ansible.cfg:

Creating a Custom Role

Creating a Custom Collection

Build and Publish

Private Galaxy Server (Automation Hub)

For enterprise environments, use a private Galaxy server:

Popular Collections

| Collection | Use Case | |-----------|----------| | community.general | General-purpose modules (1,200+) | | ansible.posix | POSIX systems (mount, sysctl, at) | | community.postgresql | PostgreSQL management | | amazon.aws | AWS cloud automation | | azure.azcollection | Azure cloud automation | | community.docker | Docker container management | | ansible.windows | Windows automation | | community.vmware | VMware vSphere automation | | kubernetes.core | Kubernetes management | | ansible.netcommon | Network automation |

FAQ

What is the difference between Ansible collections and roles?

Collections are the modern packaging format that can contain roles, modules, plugins, and playbooks. Roles are simpler — they package tasks, handlers, variables, and templates for a specific function. Collections supersede standalone roles as the primary distribution format.

Where does ansible-galaxy install collections?

By default, ~/.ansible/collections/ansible_collections/. Override with -p ./collections flag or collections_path in ansible.cfg. Project-local collections take priority over user and system paths.

How do I use a Galaxy role in a playbook?

Reference the role name in your playbook's roles section: roles: [geerlingguy.docker]. Or use include_role/import_role in tasks. Install the role first with ansible-galaxy role install.

Do I need an account to download from Ansible Galaxy?

No. Downloading and installing collections and roles from Galaxy Hub is free and doesn't require authentication. You only need an account to publish content.

How do I install collections in an air-gapped environment?

Download collection tarballs on a connected machine with ansible-galaxy collection download, then transfer to the air-gapped system and install with ansible-galaxy collection install ./tarball.tar.gz.

Conclusion

Ansible Galaxy is essential for leveraging community automation content. Use requirements.yml to manage your project dependencies, install collections for module access, and consider creating your own collections for reusable automation.

Related ArticlesAnsible Collections: What Are They and How to Use ThemAnsible Roles: Create Reusable AutomationGetting Started with Ansible

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home