DevOps Bootcamp · Lesson

Smoke Tests, Rollback & Notifications

Verify, recover and report on deploy.

Lesson 4 of 413 steps

Smoke Tests, Rollback & Notifications is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

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! 🏆

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

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

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Smoke Tests, Rollback & Notifications”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

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

Verify, recover and report on deploy. You practise DevOps Bootcamp 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 DevOps Bootcamp?

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

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 DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp 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 DevOps Bootcamp