Ok nevermind. This works now. I forgot to add become: yes to the main file in the last try. The task now calls the handler, despite the failure in the 2nd task.
So with the tasks/main.yml tasks/main.yml - name: Install nginx yum: name: nginx state: installed register: nginx_installed notify: - restart nginx - name: Run a command that fails shell: /bin/false Output - [ansible@localhost roles]$ ansible-playbook nginx.yml PLAY [localhost] *************************************************************** TASK [Gathering Facts] ********************************************************* ok: [localhost] TASK [nginx : Install nginx] *************************************************** changed: [localhost] TASK [nginx : Run a command that fails] *************************************** * fatal: [localhost]: FAILED! => {"changed": true, "cmd": "/bin/false", "delta": "0:00:00.003499", "end": "2017-09-21 15:19:14.897224", "failed": true, "rc": 1, "start": "2017-09-21 15:19:14.893725", "stderr": "", "stderr_lines": [], "stdo ut": "", "stdout_lines": []} RUNNING HANDLER [nginx : restart nginx] *************************************** * changed: [localhost] to retry, use: --limit @/etc/ansible/playbooks/roles/nginx.retry PLAY RECAP ******************************************************************** * localhost : ok=3 changed=2 unreachable=0 failed=1 -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d719dba1-5083-4f42-85bb-e615293ea7b6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.