A playbook should send a notification when it starts and when it finishes, even if it fails.
AdvancedScenarioRolling Updates, Delegation and Orchestration
Answer
Situation read → Lifecycle notifications.
What I'd do → Wrap the work in block/always, or use callback plugins. A simple pattern:
- hosts: web
tasks:
- block:
- ansible.builtin.include_role: { name: app }
always:
- community.general.slack:
token: "{{ slack_token }}"
msg: "Deploy {{ 'FAILED' if ansible_failed_task is defined else 'ok' }} on {{ inventory_hostname }}"
delegate_to: localhost
Why → always runs after both success and failure, though not if the host is unreachable.
Interview tip → AWX has native notification templates for start/success/fail.
More on Rolling Updates, Delegation and Orchestration
You must deploy a new app version to 40 web servers behind a load balancer with zero downtime.AdvancedWhat does `serial: [1, 5, "50%"]` do?BeginnerDuring a rolling update, 3 of 10 hosts in a batch fail. Does the play continue?IntermediateYou must restart database replicas one at a time but never the primary first.AdvancedYou need a task to run on the LB for every web host, without logging into each web host.IntermediateA shell command must run on localhost for each remote host, e.g. a CLI call to a cloud API.Beginner