It's probably fine. Jinja2 has some filters like "map" and "reject" but it seems difficult to do something like an "in" query and does not allow Python list comprehensions.
It would be cleaner in most people's templates if it could be done on more than one line, but it seems you cannot. Others may leverage templates more and may have some other suggestions. On Wed, May 28, 2014 at 8:12 AM, Joachim Friberg <[email protected]>wrote: > Hi, > > I'm trying to get this: > define hostgroup{ > hostgroup_name TableswitchesSweden > members dlg-prd-office-tbs01,dlg-prd-office-tbs02,dlg-prd-office- > tbs03,dlg-prd-office-tbs04,dlg-prd-office-tbs05,dlg-prd-office-tbs07,dlg- > prd-office-tbs08,dlg-prd-office-tbs10,dlg-prd-office-tbs11,dlg-prd-office- > tbs12,dlg-prd-office-tbs13,dlg-prd-office-tbs14,dlg-prd-office-tbs15,dlg- > prd-office-tbs16,dlg-prd-office-tbs17,dlg-prd-office-tbs18,dlg-prd-office- > tbs19,dlg-prd-office-tbs20 > } > > From this: > > extra_hosts: > - file_name: dlg-prd-office-tbs22 > host_check_name: tbs22 > host_checks: 'http,generic-host,base-notify' > host_check_ip: 10.0.49.71 > icon_set: network_service > type: switches > - file_name: dlg-prd-office-tbs23 > host_check_name: tbs23 > host_checks: 'http,generic-host,base-notify' > host_check_ip: 10.0.49.72 > icon_set: network_service > type: switches > - file_name: dlg-prd-office-tbs24 > host_check_name: tbs24 > host_checks: 'http,generic-host,base-notify' > host_check_ip: 10.0.49.73 > icon_set: network_service > type: switches > - file_name: dlg-prd-office-tbs25 > host_check_name: tbs25 > host_checks: 'http,generic-host,base-notify' > host_check_ip: 10.0.49.74 > icon_set: network_service > type: switches > > I was thinking about something similar to > ... > memebers {% for unit in extra_hosts[0:] %}{% if "tbs" in unit. > host_check_name %}{{ extra_hosts.file_name }}, {% endif %} {% endfor %} > ... > > > How wrong might I be? > > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/bace54f9-af6b-4ccd-9dd0-adeb318ea26a%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/bace54f9-af6b-4ccd-9dd0-adeb318ea26a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzWzStzfmHJduWngSaJazGeYkCYMBQF5sep5-ZjUoOC8g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
