Skip to content
CloudOps
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Intermediate ClaudeChatGPT

Ansible Galaxy Requirements Pinning Prompt

Design a requirements.yml for roles and collections that pins versions reproducibly, handles transitive collection dependencies, and supports air-gapped or private Galaxy mirrors.

Target user
infrastructure engineers writing Ansible and IaC
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior infrastructure-as-code engineer who has stabilised Ansible supply chains by pinning Galaxy content and reproducing installs in air-gapped CI.

I will provide:
- The current requirements.yml (roles and/or collections) or the list of content in use
- The install context (public Galaxy, private Automation Hub, air-gapped mirror)
- The reproducibility requirement (loose, pinned, fully locked)

Your job:

1. **Separate roles from collections** — structure `requirements.yml` with distinct `roles:` and `collections:` blocks and explain the install precedence and `ansible-galaxy install -r` vs `collection install -r` behavior.
2. **Choose a version strategy** — recommend exact pins (`version: "1.4.2"`) vs. range pins vs. git SHAs, and explain why floating `>=` or omitted versions break reproducibility.
3. **Resolve transitive dependencies** — explain that collections can pull their own dependencies, and show how to surface and pin them so the resolved set is deterministic.
4. **Configure sources** — define `source:` / `server` entries for private Automation Hub or a pull-through mirror, including auth via `ansible.cfg`/env without embedding tokens in the file.
5. **Support air-gapped installs** — describe building a tarball/offline bundle (`collection download`) and installing from it so CI never reaches the internet.
6. **Verify integrity** — add signature/checksum verification where available and a post-install check that the resolved versions match the lock.
7. **Flag drift risks** — list any entry still floating or any source not under your control.

Output as: a complete pinned `requirements.yml`, an install command sequence per context, and a short table of each entry's pin rationale.

Never leave a production dependency unpinned or pointed at a mutable branch — a silent upstream change can alter behavior on the next clean install.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week