Skip to main content

Ansible collection component

Build, lint, publish, and verify an Ansible collection with the ansible-collection component.

Usage

include:
- component: $CI_SERVER_FQDN/xrow-public/ci-tools/ansible-collection@stable
inputs:
name: acme.platform
path: collections/acme/platform

The component expects path to contain the collection galaxy.yml. It creates a lint job, then the build job builds the Galaxy collection artifact into release/ansible-collections/galaxy, builds a local-registry artifact into release/ansible-collections/local, publishes that local artifact to the GitLab package registry, and stores metadata artifacts with the namespace, name, and version used by publish and verify jobs.

Every successful build publishes the local-registry artifact to the GitLab generic package registry with version 0.0.0+$CI_COMMIT_SHA, then downloads the package and compares it with the built artifact. This gives each commit an immutable, verified internal package even when tag pipelines publish a semantic release version to Galaxy.

Publishing is tag-only by default and requires a Galaxy API token. Store GALAXY_TOKEN as a masked CI/CD variable with permission to publish to the configured Galaxy server, or set galaxy-token to the name of another CI/CD variable. If you override publish-rules so that publishing runs in other pipelines, the publish job still fails when the configured token variable is not available.

Use server to publish and verify against another Galaxy-compatible API endpoint. Use rules, publish-rules, galaxy-token, needs, tags, and stage to adapt the generated jobs to the project pipeline.

Inputs

NameDescriptionDefaultType
------------
galaxy-tokenCI/CD variable name containing the Galaxy API token.GALAXY_TOKENstring
imageAnsible EE image to use${CI_TOOLS_REPO}/ansible-ee:${CI_TOOLS_COMPONENT_VERSION}string
nameName for the collection pipeline jobs.xrow.commonstring
needsAdditional jobs that the collection build depends on.[]array
pathPath to the Ansible collection directory that contains galaxy.yml..string
publish-rulesRules for publishing to Galaxy. Defaults to tag-only publishing.[{"if":"$CI_COMMIT_TAG","when":"on_success"},{"when":"never"}]array
rulesRules for linting and building the collection.[{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"if":"$CI_PIPELINE_SOURCE == \"merge_request_event\"","when":"on_success"},{"when":"on_success"}]array
serverGalaxy API server used for publishing and verification.https://galaxy.ansible.comstring
stageThe pipeline stage for the build job.buildstring
tagsThe runners that these jobs depend on.[]array