Thanks for the link Brian! I experimented a bit with macros but couldn't find a working solution. These are the lines I would like to have available in a macro: https://github.com/rlenferink/ansible-function-test/blob/9c83a40a29eb616a59b4da713771545a2aa44f32/playbook.yml#L15-L16
Knowing that this is called a macro, I found the following feature request: https://github.com/ansible/ansible/issues/36130 It is mentioned in the issue that the decision was made not to add such a feature. I tried using the described workaround but wasn't successful so far: https://github.com/rlenferink/ansible-function-test/tree/macro-try Honestly using a separate file for defining this macro and then importing it for every usage also feels a bit like a workaround (since this would not something I'd do once, more like in the 100+ occurrences area). Do you know if there is an alternative to define and use macros within a playbook? Is it maybe worth reevaluating the feature request for adding support for this? Roy Op wo 13 jul. 2022 om 17:38 schreef Brian Coca <bc...@redhat.com>: > Jinja2 has this already, macros > https://jinja.palletsprojects.com/en/2.10.x/templates/#macros > > -- > ---------- > Brian Coca > > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/CAOtwSKG_XTORkrvd%3DW0qq24PC7-xag-VqcMkRjsuRh%2Bv-MpxmQ%40mail.gmail.com.