Ansible collection component
Build, lint, and publish 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.
Use the ansible-molecule or review-molecule component separately when the
collection also needs Molecule tests.
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
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| galaxy-token | CI/CD variable name containing the Galaxy API token. | GALAXY_TOKEN | string |
| image | Ansible EE image to use | ${CI_TOOLS_REPO}/ansible-ee:${CI_TOOLS_COMPONENT_VERSION} | string |
| name | Name for the collection pipeline jobs. | xrow.common | string |
| needs | Additional jobs that the collection build depends on. | [] | array |
| path | Path to the Ansible collection directory that contains galaxy.yml. | . | string |
| publish-rules | Rules for publishing to Galaxy. Defaults to tag-only publishing. | [{"if":"$CI_COMMIT_TAG","when":"on_success"},{"when":"never"}] | array |
| rules | Rules 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 |
| server | Galaxy API server used for publishing and verification. | https://galaxy.ansible.com | string |
| stage | The pipeline stage for the build job. | build | string |
| tags | The runners that these jobs depend on. | [] | array |