Thruk - templating - Add href when host is member of hostgroup

94 Views Asked by At

In the _block.tt its possible to add href when custom_vars_host is present.

[% IF custom_vars_host.size > 0 %]
[% FOREACH cust = custom_vars_host %]
[% IF cust.key == "ilo" || cust.key == "drac") %]
<td><a href='https://[% cust.value %]/'>...</a></td>
[% END %]
[% END %]
[% END %]

Is there a way to add link when host is member of a hostgroup?

2

There are 2 best solutions below

0
Mickaël X On BEST ANSWER

Same way as the macro

[% IF host.groups.size > 0 %]

[% FOREACH group IN host.groups.sort %]

[% IF group == "metrics-win" %]

[% END %]

[% END %]

[% END %]

0
sni On

extending the _block.tt template could lead to maintainance issues because you have to double check your changes after each update. You could use the new rest api together with the js action menus like in this example: https://thruk.org/documentation/action-menu.html#sending-commands