Ansible Role Dependencies & meta/main.yml Design Prompt
Design a role's meta/main.yml — dependencies, galaxy_info, platforms, and role_dependencies — so roles compose predictably without hidden ordering surprises.
- Target user
- Engineers building a library of composable roles who keep getting bitten by implicit dependency ordering and duplicate runs
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior Ansible engineer who designs `meta/main.yml` deliberately because role dependencies control execution order and deduplication — the two things that make a role library either composable or a source of baffling ordering bugs. I will describe a role and what it needs from other roles. Design its meta/main.yml and dependency strategy. Steps: 1. **galaxy_info**: fill in author, description, license, `min_ansible_version`, and supported `platforms` so the role is publishable and its constraints are explicit. 2. **dependencies vs. import/include**: decide whether a prerequisite belongs as a `meta` dependency (runs before this role's tasks, deduplicated) or as an explicit `import_role`/`include_role` in tasks (visible, ordered where you put it) — and justify the choice. 3. **Dedup behavior**: set `allow_duplicates` explicitly where a dependency must run more than once (e.g. per-instance setup), and explain the default dedup by name+params. 4. **Parameterization**: pass required vars to dependencies via `role: name` with params, keeping the dependency's contract clear. 5. **Resolved order**: produce the full flattened run order so no ordering is hidden. 6. **Verification**: show how to confirm order with a check-mode run and `--list-tasks`. Fill in: - Role purpose: [DESCRIBE] - Prerequisites it needs: [LIST] - Any prerequisite that must run per-instance: [YES/NO — which] Output format: an annotated meta/main.yml, a dependencies-vs-explicit-include recommendation with rationale, the flattened execution order, and the --list-tasks verification step.
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
meta/main.yml is where role libraries quietly earn their reputation for baffling ordering bugs, because role dependencies run before the role’s own tasks and are deduplicated by name-plus-params by default. This prompt forces the two decisions that actually matter: whether a prerequisite belongs as a meta dependency or as an explicit import_role/include_role you can see in the task list, and whether allow_duplicates needs to be set so a per-instance setup role isn’t silently skipped on its second use.
Making the resolved execution order explicit is the payoff. Deep dependency chains hide ordering, so a change to one shared dependency can alter every dependent role’s behavior without any of them changing. By ending on a flattened order plus --list-tasks verification, the prompt turns dependency composition from something you discover at runtime into something you can read and confirm before it touches a host.
Related prompts
-
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.
-
Refactor Ansible Tasks into a Reusable Role Prompt
Extract a sprawling set of inline playbook tasks into a clean, parameterized Ansible role with proper defaults, vars, handlers, and a Galaxy-standard directory layout.
-
Ansible Monolith to Roles Refactor Prompt
Break a long monolithic playbook into clean, reusable roles with proper defaults/vars/handlers split and a behavior-preserving migration plan.
-
Ansible Callback Plugin Authoring Prompt
Draft a custom callback plugin that hooks play/task events for profiling, structured logging, or notifications without changing any playbook.
More Ansible prompts & error guides
Browse every Ansible prompt and troubleshooting guide in one place.
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.