I'm using Ansible to provision my development server.
I want it to always start some services for me. I have handlers for this purpose but what is the best way to trigger handler execution without condition, e.g. make it always work?
Something like this:
tasks:
- name: Trigger handler
run_handler: name=nginx-restart
Best Answer
If you absolutely need to trigger a handler every time then here are two options:
1) run a noop shell command which will always report as changed
2) use debug along with changed_when: to trigger a handler
Also of note for Option 1 and Check Mode: You may want to use
check_mode: no
if using Ansible version 2.2 or higher oralways_run: yes
if using earlier versions than that so that the task does not get skipped over in check mode. From my manual testing it looks like the handlers remain in check mode, but please be careful as your case may differ.