Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Fixing an Ansible Lint No-Handler Error in a Multi-Condition Task

fixing-an-ansible-lint-no-handler-error-in-a-multi-condition-task.jpg

You may have a more complicated when condition where it's not obvious on how convert it into a handler. Here's what I did.

Quick Jump:

I ran across this use case the other day where I had a when ... is changed condition that had an or condition and it wasn’t really clear on how to convert that into a handler.

What I ended up doing was simplifying the condition by performing one of the conditions in the shell script that I was running in the task. After doing that, converting the single when condition into a handler was easy.

Here’s a video walk through of the exact use case and how I fixed it.

# Going Over an Example

Timestamps

  • 0:26 – What causes a no-handler linting error and how to fix it usually
  • 1:11 – Breaking down the task that caused this error
  • 2:02 – How you can normally fix the error with a more simple when condition
  • 2:45 – My task was a bit more complicated with its when condition
  • 3:23 – Ansible is nice but I don’t use it for everything
  • 5:44 – Solving this specific problem by doing the existence check in the shell script
  • 8:11 – Maciej was on my podcast to talk about how he’s using Ansible

Reference Links

How would you have solved this problem? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments