Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Ansible Difficulty: Advanced ClaudeChatGPTCursor

Ansible Galaxy Collection Build & Publish Workflow Prompt

Design a repeatable build, version, and publish pipeline for an Ansible collection to Galaxy or a private Automation Hub, with semver and provenance.

Target user
Platform teams packaging internal roles/modules into a versioned collection for controlled distribution
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior Ansible engineer who ships internal automation as a versioned collection because a collection gives you FQCN namespacing, dependency pinning, and a single artifact to distribute — not a pile of loose roles copied between repos.

I will describe a collection I need to build and publish. Design the full workflow.

Steps:

1. **galaxy.yml**: define namespace, name, version (semver), dependencies, and metadata; explain how version drives the artifact name and why it must be bumped on every publish.
2. **Structure**: lay out `plugins/`, `roles/`, `playbooks/`, and `meta/runtime.yml` (with `requires_ansible`) so the collection is valid.
3. **Build**: `ansible-galaxy collection build` to produce the tarball; show the deterministic artifact name.
4. **Pre-publish gates**: run `ansible-lint`, `ansible-test sanity`, and any unit/integration tests in CI before a publish is ever allowed.
5. **Publish**: `ansible-galaxy collection publish path/to/tarball --api-key` against Galaxy or a private Automation Hub, triggered only on a git tag with manual approval.
6. **Versioning and immutability**: enforce that each publish is a new semver and explain that a version is immutable once uploaded.

Fill in:
- Namespace and collection name: [ns.name]
- Distribution target: [public Galaxy / private Automation Hub URL]
- CI system: [GitHub Actions / GitLab CI]
- Dependencies to pin: [LIST]

Output format: an annotated galaxy.yml, the directory layout, the CI pipeline stages (lint → sanity → build → tag-gated publish), and the exact ansible-galaxy commands.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Distributing internal automation as loose roles copied between repositories is how drift and “which version is prod running?” confusion start. A collection collapses that into one versioned, FQCN-namespaced artifact with pinned dependencies. This prompt builds the whole pipeline around that discipline, from a correct galaxy.yml through the exact ansible-galaxy collection build and publish commands.

The two guardrails reflect the parts that bite teams in production. A publish is immutable: once a version lands on Galaxy or Automation Hub, that content is frozen, so a broken build shipped as 1.4.0 is 1.4.0 forever and everyone pulls it. Gating publish behind a git tag, green sanity tests, and manual approval prevents that. And because the API token grants namespace-wide publish rights, keeping it out of galaxy.yml and in a scoped CI secret is non-negotiable.

Related prompts

More Ansible prompts & error guides

Browse every Ansible prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.