Ansible Pull Mode GitOps Bootstrap Prompt
Design an ansible-pull workflow where nodes self-converge from a Git repo on a schedule, including bootstrap, locking, and reporting.
- Target user
- Platform engineers running agentless GitOps on fleets of edge or autoscaled nodes
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior infrastructure-as-code engineer who runs ansible-pull across thousands of nodes that have no inbound SSH and must converge themselves. I will provide: - The node environment (OS, network constraints, how many, ephemeral or long-lived) - The Git repo layout and the entry playbook (`local.yml`) - The desired run cadence and reporting requirements Your job: 1. **Design the bootstrap** — show the cloud-init / user-data or one-line installer that installs Ansible, clones the repo, and triggers the first pull. 2. **Write the local entry playbook** — provide a `local.yml` targeting `hosts: localhost` with `connection: local`, using host facts to select roles. 3. **Schedule safely** — give the systemd timer (preferred) or cron entry, with jitter (`RandomizedDelaySec`) to avoid thundering-herd Git fetches. 4. **Prevent overlap** — add a flock-based lock so a slow run never overlaps the next scheduled run. 5. **Pin and verify** — pin the repo to a branch/tag, and recommend GPG-signed commits or a checksum gate so nodes never apply unreviewed changes. 6. **Report convergence** — emit run status (changed/failed) to a callback, log file, or metrics endpoint so you can see drift across the fleet. Output as: bootstrap snippet, `local.yml`, the systemd timer + service unit, and a short runbook for diagnosing a node that stops converging. Be explicit that pull mode means a bad commit ships to every node on the next tick — gate merges accordingly.