Brian Coca
unread,May 30, 2024, 12:28:56 PMMay 30Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
First of all, both are valid ways of writing conditionals.
From the execution standpoint, the main difference is that the list
version will be evaluated in order, one at a time by Ansible passing
each item to Jinja. While the other one will be passed as one item
into Jinja. This creates a minor change in efficiency depending on the
amount of conditions and the likelyhood of failure, but for most cases
(less than 100 conditionals) I would consider it negligible.
From a practical standpoint, the 2nd form is easier to put into a
variable and compose 'ANDed' conditions by adding to a list, you only
need to ensure each condition's correctness, not the aggregated whole.
The first form on the other hand supports 'OR' conditions also.
In the end I would consider it a preference issue, though most Ansible
users are used to the 2nd form and might get confused by the first,
but that is only a consideration when/if sharing the content.
--
----------
Brian Coca (he/him/yo)