{% set postfix__tpl_dependent_mastercf = {} %}
{% if (postfix__register_dependent_mastercf|d() and postfix__register_dependent_mastercf.content|d()) %}
{%   set _ = postfix__tpl_dependent_mastercf.update(postfix__register_dependent_mastercf.content | b64decode | trim | from_json) %}
{% endif %}
{% if postfix__dependent_mastercf %}
{%   set postfix__tpl_flattened_mastercf = lookup('flattened', postfix__dependent_mastercf) %}
{%   for element in ([ postfix__tpl_flattened_mastercf ] if postfix__tpl_flattened_mastercf is mapping else postfix__tpl_flattened_mastercf) %}
{%     if element.role|d() and element.config|d() %}
{%       if element.state|d('present') not in [ 'ignore', 'absent' ] %}
{%         set flattened_config = lookup('flattened', element.config) %}
{%         set _ = postfix__tpl_dependent_mastercf.update({
  element.role: ([ flattened_config ] if flattened_config is mapping else flattened_config)
}) %}
{%       elif element.state|d('present') == 'absent' %}
{%         set _ = postfix__tpl_dependent_mastercf.pop(element.role, None) %}
{%       endif %}
{%     elif element is mapping and 'role' not in element.keys() and 'config' not in element.keys() %}
{%       for role, config in element.items() %}
{%         set flattened_config = lookup('flattened', config) %}
{%         set _ = postfix__tpl_dependent_mastercf.update({
  role: ([ flattened_config ] if flattened_config is mapping else flattened_config)
}) %}
{%       endfor %}
{%     endif %}
{%   endfor %}
{% endif %}
{{ postfix__tpl_dependent_mastercf | to_nice_json }}
