Anisble - Collection

> Infrastructure as code > Ansible

1 - About

Collections are a distribution format that package:

  • playbooks,
  • roles,
  • modules,
  • and
  • plugins.

You can publish and use collections through Ansible Galaxy.

Advertising

3 - Example

4 - Management

4.1 - Create

ansible-galaxy collection init  my_namespace.my_collection

Example: https://github.com/bcoca/collection

4.2 - Build

Build the collection into a collection artifact

ansible-galaxy collection build

creates a tarball of the built collection in the current directory which can be uploaded to Galaxy.:

my_collection/
├── galaxy.yml
├── ...
├── my_namespace-my_collection-1.0.0.tar.gz
└── ...

4.3 - Publish

Publish the collection artifact to Galaxy

ansible-galaxy collection publish
# or
ansible-galaxy collection publish path/to/my_namespace-my_collection-1.0.0.tar.gz --api-key=SECRET
Advertising

4.4 - Install

From the tarball created during the build

ansible-galaxy collection install my_namespace-my_collection-1.0.0.tar.gz -p ./collections

5 - Documentation