Collection

Learn how to reuse our code using Ansible collections from the Ansible Galaxy online archive.

What is an Ansible collection?

An Ansible collection is a comprehensive and contemporary method for distributing Ansible code across multiple platforms. It provides a standardized approach to distributing Ansible roles, modules, and plugins. Typically, collections are published in the public Ansible Galaxy website archive. An Ansible collection serves as a distribution format for various Ansible content.

Through Ansible collections, a single package resolves dependencies and includes all the necessary components, such as playbooks, roles, modules, and plugins. Users can easily download and share Ansible collections through Ansible Galaxy without needing to understand the underlying complexities. For developers, uploading and sharing an Ansible collection via Ansible Galaxy is a straightforward process.

It is important to note that all files associated with an Ansible collection should be located within the collections directory of the project.

The community.general collection

The most comprehensive collection archive is community.general, and it has a lot of valuable Ansible resources. The archive is distributed with a community license. This means that the Ansible community is doing its best to support the product, but there is no specific time for a bug fix or new feature implementation.

Let’s suppose we would like to use the iso_create Ansible module from the community.general Ansible Galaxy collection in our system. The iso_create module creates an ISO image from a list of files in our system. It’s useful for backup purposes. In order to use the iso_create module, we need to specify the entire Ansible namespace in our task: community.general.iso_create.

For example, the following Ansible playbook creates the test.iso file from a list of files:

Get hands-on with 1400+ tech skills courses.