Fixing an Ansible Lint No-Handler Error in a Multi-Condition Task
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.
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.