Ansible Galaxy is the official hub for sharing Ansible content — collections, roles, and plugins created by the community and vendors. Collections bundle modules, plugins, roles, and playbooks into distributable packages. This guide covers finding, installing, and using Galaxy collections effectively in your automation workflows.
Understanding Collections vs Roles
- Roles: Reusable task bundles focused on a single purpose (e.g., "install nginx")
- Collections: Packages of roles, modules, plugins, and playbooks — the modern standard
Collection Naming
# Collections use namespace.collection format:
# community.general — Community-maintained general modules
# community.docker — Docker management
# community.postgresql — PostgreSQL management
# ansible.posix — POSIX system modules
# amazon.aws — AWS cloud modules
# hetzner.hcloud — Hetzner Cloud
Installing Collections
# Install a single collection
ansible-galaxy collection install community.docker
ansible-galaxy collection install community.postgresql
# Install with a specific version
ansible-galaxy collection install community.general:>=8.0.0
# Install from a requirements file (recommended)
cat > requirements.yml