0Pricing
Ansible Academy · Lesson

Smoke Tests, Rollback & Notifications

Verify, recover and report on deploy.

Smoke Tests, Rollback & Notifications is a free Ansible Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Deploy Is Not Done at Reload

A finished play is not a working app. You still need smoke tests, a rollback path and a notification. Close the loop. 🔁

Smoke Test the Endpoint

Hit a real route with the uri module and assert a 200. If the app does not answer correctly, the deploy should fail loudly.

- name: Smoke test
  ansible.builtin.uri:
    url: https://app.example.com/health
    status_code: 200
    return_content: true

Assert the Right Version

Go further: read the response and use assert to confirm the live version matches the one you just shipped.

- ansible.builtin.assert:
    that:
      - "app_version in smoke.content"
    fail_msg: "Wrong version live"

Wrap Deploy in a block

Group deploy plus tests inside a block so a single failure can trigger one shared recovery path.

- block:
    - import_role:
        name: deploy
    - import_tasks: smoke.yml

Rollback in rescue

Put the undo logic in rescue: redeploy the previous version so a failed release never leaves users on broken code.

  rescue:
    - name: Roll back
      ansible.builtin.git:
        repo: "{{ app_repo }}"
        version: "{{ previous_version }}"
        dest: /srv/app

Always Re-Enable Traffic

Use always to put the node back behind the load balancer whether the deploy passed or rolled back. Never strand a host.

  always:
    - community.general.haproxy:
        state: enabled
        host: "{{ inventory_hostname }}"
      delegate_to: lb1

Fail Fast, Fail Clear

When something is wrong, stop with a useful message using the fail module, so the log says exactly what broke.

- ansible.builtin.fail:
    msg: "Health check failed on {{ inventory_hostname }}"

Notify the Team

Report the outcome. A community.general.slack task posts success or failure so humans know the deploy finished.

- community.general.slack:
    token: "{{ slack_token }}"
    msg: "Deployed {{ app_version }} ✅"

Email or Chat, Your Choice

Prefer email? The mail module sends a summary. Any channel works; the point is a clear, automatic deploy signal.

- community.general.mail:
    to: ops@example.com
    subject: "Deploy {{ app_version }} complete"

Keep the Last Good Version

Rollback only works if you tracked it. Record previous_version before deploying so rescue knows what to restore.

vars:
  previous_version: "2.4.0"
  app_version: "2.4.1"

A Deploy You Can Trust

Test, roll back on failure, always restore traffic, and tell the team. That is a production-grade deploy, end to end. 🎉

Quick Check

One section guarantees traffic is restored.

Recap

You closed the loop: smoke tests, rollback in rescue, re-enable in always, and team notifications. Capstone complete! 🏆

Frequently asked questions

Is the “Smoke Tests, Rollback & Notifications” lesson free?

Yes — the full text of “Smoke Tests, Rollback & Notifications” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.

What will I learn in “Smoke Tests, Rollback & Notifications”?

Verify, recover and report on deploy. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ansible Academy?

No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Smoke Tests, Rollback & Notifications” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ansible Academy lesson?

Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Architect the Project: Roles & Inventory
  2. Provision, Harden & Bootstrap Hosts
  3. Rolling Deploy Behind the Load Balancer
  4. Smoke Tests, Rollback & Notifications
← Back to Ansible Academy