Skip to content

Case Study: API Automation with URI

Section status: outline

This case study is scoped but not yet written in full prose. The sections below define what it will cover.

Problem

Every newly deployed host needs to register itself with an internal service registry over HTTP as the last step of provisioning, and deregister cleanly on decommission.

What It Will Cover

  • ansible.builtin.uri for both the registration POST and a decommission DELETE, full example building on URI and API Automation
  • retries/until for a registry that's occasionally briefly unavailable, instead of failing the whole deploy on one transient blip
  • Structured error handling: failed_when checking the JSON response body's own status field, not just the HTTP status code
  • no_log on the registration token, and confirming with -vvv it never surfaces

Interview Questions

  • How would you make an API-registration task resilient to a brief, transient outage of the target service?
  • Why check the response body's own status field in addition to the HTTP status code?

Next

Continue to Troubleshooting.