Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

How would you delay a restart until a maintenance window?

AdvancedScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Changes should apply now but disruptive actions later.

What I'd do →

  1. Let the config deploy normally and write a flag file or notify a handler that only sets a "restart pending" marker.
  2. A scheduled AWX job (or cron on the controller) runs a play with tags: restart inside the window.
  3. Report pending restarts using needs-restarting -r or /var/run/reboot-required.

Why → Separating configuration from disruption keeps deploys safe and auditable.

Interview tip → Mention AWX schedules with a survey-less, tag-limited template.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency