Hello,
I have a role handler that I use to restart instances of node-logstash ; basically it does
// roles/logstash/handlers/main.yml
- name: restart logstash service
service: name={{ item.initd_script }} state=restarted
sudo: yes
sudo_user: root
when: item.state == “started”
with_items: instances
where instances is defined in // roles/logstash/vars/main.yml
the role also takes care of node-logstash installation.
I would like to re-use this handler from another play where the role is not invoked but it breaks because since the role is not invoked, the handler is not defined (and the variable either).
I cannot just include the handler file because I will miss the vars.
Is there a possibility to invoke a role without playing its tasks / dependencies ?
Do you see a way to organize things so that this handler, along with its vars could be called easily from another play ? should I create a new role “logstash_common” with an empty “tasks” directory and invoke it where I need the handler ?
Thanks