{# Copyright (C) 2015 Maciej Delmanowski <drybjed@gmail.com>
 # Copyright (C) 2015 DebOps <https://debops.org/>
 # SPDX-License-Identifier: GPL-3.0-only
 #}
{% set iscsi__tpl_iqn = ansible_local.iscsi.iqn|d(iscsi__iqn) %}
{% set iscsi__tpl_discovered_portals = [] %}
{% if ansible_local.iscsi.discovered_portals|d() %}
{% set iscsi__tpl_discovered_portals = ansible_local.iscsi.discovered_portals %}
{% endif %}
{% if iscsi__register_discover_targets|d() and iscsi__register_discover_targets.results|d() %}
{% for element in iscsi__register_discover_targets.results %}
{% if "item" in element.keys() %}
{% set _ = iscsi__tpl_discovered_portals.append(element.item) %}
{% endif %}
{% endfor %}
{% endif %}
{
"iqn":"{{ iscsi__tpl_iqn }}",
"discovered_portals": {{ iscsi__tpl_discovered_portals | unique | to_nice_json }}
}
