Example CI/CD Pipeline for an Ansible Collection
Example CI/CD Pipeline for an Ansible Collection
To streamline the development and release process of Ansible collections, you can create a CI/CD pipeline that includes code validation and manual steps for releasing a new version of an Ansible collection to Ansible Galaxy.
To streamline the development and release process of Ansible collections, you can integrate Git with CI/CD pipelines. The example .gitlab-ci.yml
file attached to this page provides a template pipeline that includes code validation and manual steps for releasing a new version of an Ansible collection to Ansible Galaxy.
The file contains the configuration for the pipeline stages and jobs:
The prepare
job in the build stage extracts the collection version, name, and namespace from the galaxy.yml
file and saves them as environment variables for later use. It creates a variables.env
file to store these variables as artifacts.
The build
job packages the Ansible collection and generates the README.md
file from README-GALAXY.md
. The resulting collection is stored as an artifact.
The yamllint
job runs the yamllint
tool to validate the YAML code.
The ansible-lint
job installs the collection built in the previous stage and runs the ansible-lint
tool to validate the Ansible code.
The publish
job publishes the Ansible collection to Ansible Galaxy. It packages the collection, generates the README.md
file from README-GALAXY.md
, and publishes it to Ansible Galaxy using the provided API key.
The gitlab-release
job creates a release in GitLab for the Ansible collection. It uses the information from galaxy.yml
, including the version and changelog, to create the release. The release is associated with the commit and can be accessed through the provided release name.
To use this pipeline as a template for your Ansible collections, follow these steps:
.gitlab-ci.yml
and galaxy.yml
..gitlab-ci.yml
file based on your specific requirements. Copy the updated pipeline configuration provided below.galaxy.yml
file with the relevant information for your Ansible collection, such as the namespace, name, version, description, and links to documentation and issues.before_script
section of the .gitlab-ci.yml
file if needed.GALAXY_API_KEY
for publishing to Ansible Galaxy.By integrating Git with CI/CD pipelines for Ansible collections, you can achieve the following benefits:
.gitlab-ci.yml
of the Ansible collection c2platform.gis
. This project also includes an Azure CI/CD pipeline see azure-pipelines.yml
.Example CI/CD Pipeline for an Ansible Collection
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.