Ansible Collections Registry

Publish Ansible collections for your user or organization.

Requirements

To work with the Ansible collection registry, you can use the ansible-galaxy CLI tool.

Configuring the collections registry

To configure ansible-galaxyto use the registry, you can add the server in the ansible.cfg file:

[galaxy]
server_list = my_forgejo, release_galaxy

[galaxy_server.my_forgejo]
url=https://forgejo.example.com/api/packages/{owner}/ansible/
token={access_token}

Alternatively, you can configure the CLI through the parameters --server https://forgejo.example.com/api/packages/{owner}/ansible/ and --token {access-token}.

ParameterDescription
access_tokenYour personal access token.
ownerThe owner of the collection.

Publish a collection

To publish a collection you first have to build the collection, according to (https://docs.ansible.com/ansible/latest/dev_guide/developing_collections_distributing.html#building-your-collection-tarball).

Then you can publish the collection:

ansible-galaxy collection publish --server https://forgejo.example.com/api/packages/{owner}/ansible/ --token {access-token} {collection_archive}
ParameterDescription
access_tokenYour personal access token.
collection_archiveThe .tar.gz archive of the collection to deploy.
ownerThe owner of the collection.

You cannot publish a collection if a collection of the same name and version already exists. You must delete the existing collection first.

Install a collection

To install an Ansible collection run the following command:

ansible-galaxy collection install --server https://forgejo.example.com/api/packages/{owner}/ansible/ {collection_name}
ParameterDescription
collection_nameThe qualifier of the collection in the format {namespace}.{name}.
ownerThe owner of the collection.

If you want to add the collection to a requirements.yml file, you can add the following block:

- name: '{collection_name}'
  source: 'https://forgejo.example.com/api/packages/{owner}/ansible/'