I eventually settled on having a dedicated role that contains all the
handlers we use, and nothing else:
$ tree roles/handlers
roles/handlers
├── README.md
└── handlers
└── main.yml
That is then include early on in the plays:
tasks:
- name: Ensure shared handler role is imported
ansible.builtin.import_role:
name: handlers
It is a bit clunky but it does work and at least the handlers are defined
only once.
Dick
On Fri, 25 Aug 2023 at 00:10, Vladimir Botka <[email protected]> wrote:
> On Thu, 24 Aug 2023 17:46:58 +0200
> Dick Visser <[email protected]> wrote:
>
> > Is there perhaps another way to avoid having a ton of very similar)
> > handlers?
>
> It is not, IMHO, if you want to do it in a single run of a playbook.
>
> It is possible to create handlers from meta-data and template(s) and
> then import them. Similar to the concept of the *configure* script
> https://en.wikipedia.org/wiki/Configure_script
>
> I'm not saying Ansible should generally adopt this concept. I think,
> in some cases such configuration might make the project robuster,
> simpler, and easily extendable. FWIW, it's feasible to control some
> projects by structured meta-data only
> https://ansible-config-light.readthedocs.io/en/latest/qsg.html
>
>
> --
> Vladimir Botka
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAF8BbLZmcDmo93Sq908_O439%3D39fh4MBD-JZ8_Un7AqqigFvbQ%40mail.gmail.com.