ansible-galaxy

Manage Ansible roles and collections from Galaxy

TLDR

Install a role from Galaxy
$ ansible-galaxy install [username.role_name]
Install collection from Galaxy
$ ansible-galaxy collection install [community.docker]
Install from requirements file
$ ansible-galaxy install -r [requirements.yml]
List installed roles
$ ansible-galaxy list
Initialize a new role
$ ansible-galaxy init [role_name]
Search for roles
$ ansible-galaxy search [nginx]

SYNOPSIS

ansible-galaxy [role|collection] command [options]

DESCRIPTION

ansible-galaxy manages Ansible roles and collections from Ansible Galaxy and other sources. Galaxy is a public repository of community-contributed content, providing reusable automation components.The tool can install, create, and manage roles (traditional content) and collections (bundled content including modules, plugins, and roles). Subcommands are grouped by content type as ansible-galaxy role command and ansible-galaxy collection command; if the type is omitted, role is assumed (for example, "ansible-galaxy install" is equivalent to "ansible-galaxy role install").

PARAMETERS

install name

Install a role (or use "collection install" for a collection)
init name
Create a new role or collection scaffold
list
List installed roles or collections
search query
Search Galaxy for roles
info name
Show detailed information about a role or collection
remove name
Remove an installed role or collection
build
Build a collection artifact (collection only)
publish tarball
Publish a collection to a Galaxy server (collection only)
-r file, --role-file file, --requirements-file file
Install items listed in a YAML requirements file
-p path, --roles-path path
Installation path for roles (--collections-path for collections)
--force
Force overwrite of an existing role or collection
-s server, --server server
Galaxy API server URL
--offline
Work offline (init/install/verify, using installed content only)

CONFIGURATION

/etc/ansible/ansible.cfg

System-wide Ansible configuration, including Galaxy server URL and roles path.
~/.ansible.cfg
Per-user Ansible configuration overriding system defaults.
ansible.cfg
Project-level configuration in the current directory, highest priority.

INSTALL

sudo dnf install ansible-core
sudo pacman -S ansible-core
sudo apk add ansible-core
sudo zypper install ansible-core

CAVEATS

Galaxy content is community-maintained; review before use in production. Collection names are namespaced (namespace.collection). Roles and collections have different installation paths.

HISTORY

ansible-galaxy was introduced with Ansible Galaxy in 2013 to share and distribute roles. Collections support was added in Ansible 2.9 (2019) as a new content distribution format.

SEE ALSO

ansible(1), ansible-playbook(1), ansible-doc(1)

RESOURCES

Source code · Documentation