Interview Prep/Ansible/Rolling Updates, Delegation and Orchestration

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.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Orchestration